Illegal instruction (core dumped) after running import tensorflow
As explained in the accepted answer, this issue can be fixed either by installing older version of TensorFlow (v1.5) or building from source. Between the two, building from source is arguably a preferred route despite the additional effort. Granted that the binary contains the most updated components of TensorFlow.
This article explains how to build TensorFlow from sources and optimizes for the older CPU. The key is in detecting the CPU flags and enable all the CPU flags for optimization when configuring the build.
The following command is used to detect common CPU optimization flags:
$ grep flags -m1 /proc/cpuinfo | cut -d ":" -f 2 | tr '[:upper:]' '[:lower:]' | { read FLAGS; OPT="-march=native"; for flag in $FLAGS; do case "$flag" in "sse4_1" | "sse4_2" | "ssse3" | "fma" | "cx16" | "popcnt" | "avx" | "avx2") OPT+=" -m$flag";; esac; done; MODOPT=${OPT//_/\.}; echo "$MODOPT"; }
If by executing the command, -mavx
and/or -mavx2
is not shown, it can be confirmed that AVX support is missing and the source build should be done with other optimization flags displayed in the output.
In a related article, the common root cause of this issue is discussed in more details, which is provided as an additional reference.
I would use older version. Looks like your CPU does not support AVX instructions.
Quoting from their Release Page
Breaking Changes
Prebuilt binaries are now built against CUDA 9.0 and cuDNN 7.
Prebuilt binaries will use AVX instructions. This may break TF on older CPUs.
You have atleast two options:
Use tensorflow 1.5 or older
Build from source
Regarding your concern for differences, you will miss out on new features, but most basic features and documentations are not that different.
Unfortunately, 1.6 has given many people the same error. I received it after installing 1.7 on a machine with an old Core2 CPU. I've settled with 1.5, as I can't fit the big graphics card in the machine with the up-to-date processor!