Illegal instruction(core dumped) tensorflow

I had the same problem and had to downgrade tensorflow to 1.5.0:

pip uninstall tensorflow
pip install tensorflow==1.5.0

Edit: As @Tobsta points out in the comments, the other option is to compile the binaries from source. The precompiled binaries of versions >1.5 use AVX instructions that are not supported by older CPUs


I see same message on my PC / Celeron N4000.

$ python3 -c "import tensorflow as tf; print(tf.__version__)"
Illegal instruction (core dumped)

I successed to build TensorFlow v1.14.0 without AVX instruction. (Just build TensorFlow on CeleronN4000)

$ python3 -c "import tensorflow as tf; print(tf.__version__)"
1.14.0

I wrote the log on below.
https://github.com/naruai/wiki/blob/master/TensorFlow/BuildTensorFlowWOAVX.md

In my case, used Python 3.6.8 .
I also tested with Python 2.7 .
About Python 3.5 , I not tested.
Maybe possible to use similar way, I think.


The desired version of TensorFlow can be installed via a hack using anaconda. First, go to the directory which has sufficient space and download anaconda there (Check the version you want to install).

curl -O https://repo.anaconda.com/archive/Anaconda3-2019.03-Linux-x86_64.sh

If you want to ensure the integrity of the Anaconda installed check it using SHA-256.

sha256sum Anaconda3-2019.03-Linux-x86_64.sh

Run the Anaconda Script:

bash Anaconda3-2019.03-Linux-x86_64.sh

Output should be like:

45c851b7497cc14d5ca060064394569f724b67d9b5f98a926ed49b834a6bb73a  Anaconda3-2019.03-Linux-x86_64.sh

Now when you get the prompt: Anaconda3 will be installed in this location: ….

Enter the location where you want it to be installed or press enter to continue.

Now as per your choice/requirement you can type yes/no for “Do you wish the installer to initialize Anaconda3 by running conda init?”

Now instead of using pip for installing tensorflow, we will use conda but for this we will have to first set the path using the vim ~/.bashrc file.

# added by Anaconda3 installer
export PATH="/anaconda3/bin:$PATH"

Put your own path instead of /anaconda3/bin, like: /data/anaconda3/bin, or whatsoever.

To make this effective, run:

source ~/.bashrc

Now create a virtual environment.

conda create -n tf_env
source /anaconda3/bin/activate tf_env

Now to install TensorFlow or Keras, run:

conda install tensorflow
conda install keras

or, if there is a particular version that you want to install say, version 1.14.0 for TensorFlow and 2.3.1 for Keras.

conda install tensorflow==1.14.0
conda install keras==2.3.1

You have to be in the same virtual environment as while installing Keras and/or TensorFlow for it to work properly. Tn this case tf_env by running source /anaconda3/bin/activate tf_env

You can check the installation by running

$ python3 -c "import tensorflow as tf; print(tf.__version__)"
1.14.0