Illegal insruction (core dumped) when running keras's mnist_cnn.py example

1,451 views
Skip to first unread message

peter cohen

unread,
Apr 3, 2018, 10:10:01 AM4/3/18
to Keras-users
Hello, I reinstalled ubuntu linux 17.10.1, python3, tensorflow (no GPU version), numpy and related libraries as well as keras using the following commands described in Mr. Chollet's book.

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install python3-pip python3-dev

sudo pip3 install tensorflow

sudo apt-get install build-essential cmake git unzip pkg-config libopenblas-dev liblapack-dev

sudo apt-get install python3-numpy python3-scipy python3-matplotlib python3-yaml

sudo apt-get install libhdf5-serial-dev python3-h5py

sudo apt-get install graphviz
sudo pip3 install pydot-ng

sudo apt-get install python3-opencv

sudo pip3 install theano

git clone https://github.com/fchollet/keras
cd keras
sudo python3 setup.py install


------------------------


Then, when I issued the command:

python3 examples/mnist_cnn.py

I got the following error:

/usr/lib/python3/dist-packages/h5py/__init__.py36: FutureWarning: Conversion of the second argument of issubdtype from 'float' to 'np.floating' is deprecated.
In future, it will be treated as 'np.float64 == np.dtype(float).type'. from ._conv import register_converters as _register_converters
Using TensorFlow backend.
Illegal instruction (core dumped)

Could you please let me know how to fix this problem? Thank you.

Daπid

unread,
Apr 3, 2018, 1:21:51 PM4/3/18
to peter cohen, Keras-users
> sudo pip3 install tensorflow

Never sudo-pip anything. You are messing with your system's Python, that is a recipe for disaster, be it wrong functionality, or an unusable system alltogether.

Try to clean up your system, use your package manager to reinstall any Python package that you may have overwritten. Then, create a virtual a virtual environment, and pip any library you want.


Once you have done that, if it still persists, what is your CPU? [1] The prebuilt wheels of Tensorflow require AVX [2], you should check if your machine can do that [3], otherwise, you'd have to compile from source, or adjust your keras.json to use Theano.


/David.

[1] Run the command lscpu
[3] See with " lscpu | grep avx "

--
You received this message because you are subscribed to the Google Groups "Keras-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to keras-users+unsubscribe@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/keras-users/a72bfc41-7458-409f-80b2-3a295b967e6f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

peter cohen

unread,
Apr 3, 2018, 6:28:23 PM4/3/18
to Keras-users
Hi David,

Thanks for the warning. I did not know about the sudo-pip issue. I just followed the commands listed in Mr. Chollet's book (I changed python to python3 and pip to pip3 as I use python3).
Given that I have messed up the system, I shall reinstall Ubuntu Linux and let's start all over again.

1. If I install virtual environment, will the simulations slow down?
2. My CPU is Intel Core i7 2.66GHz of about 8 years old. My GPU is Nvidia GeForce GT 330M which is too old to be compatible with the gpu version of tensorflow.
3. I need to install Python3, Numpy, SciPy, Basic Linear Algebra Subprogram (BLAS), HDF5, Graphviz, Keras, TensorFlow, Theano, Keras. Which ones should be installed using Ubuntu's package manager and in what order? Is it possible to provide a step by step guide?

Thanks.



2018年4月3日火曜日 13時21分51秒 UTC-4 David Menéndez Hurtado:
To unsubscribe from this group and stop receiving emails from it, send an email to keras-users...@googlegroups.com.

Daπid

unread,
Apr 3, 2018, 8:27:05 PM4/3/18
to peter cohen, Keras-users
On 4 April 2018 at 00:28, peter cohen <peterco...@gmail.com> wrote:
Hi David,

Thanks for the warning. I did not know about the sudo-pip issue. I just followed the commands listed in Mr. Chollet's book (I changed python to python3 and pip to pip3 as I use python3).
Given that I have messed up the system, I shall reinstall Ubuntu Linux and let's start all over again.

A full reinstall is probably not necessary.



1. If I install virtual environment, will the simulations slow down?

No. It is not a virtual machine, it will run at the same speed.
 
2. My CPU is Intel Core i7 2.66GHz of about 8 years old. My GPU is Nvidia GeForce GT 330M which is too old to be compatible with the gpu version of tensorflow.

Which CPU model exactly (lscpu) ? Does it support AVX?
 
3. I need to install Python3, Numpy, SciPy, Basic Linear Algebra Subprogram (BLAS), HDF5, Graphviz, Keras, TensorFlow, Theano, Keras. Which ones should be installed using Ubuntu's package manager and in what order? Is it possible to provide a step by step guide?


Use apt to get python-dev, HDF5, and openblas, including devel versions. Then, use pip for any Python library. I don't use Ubuntu, so I don't have a list of commands.


To unsubscribe from this group and stop receiving emails from it, send an email to keras-users+unsubscribe@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/keras-users/0019309f-299e-48db-bbe5-3ef0763a05aa%40googlegroups.com.

peter cohen

unread,
Apr 3, 2018, 9:08:04 PM4/3/18
to Keras-users
I already reinstalled Ubuntu again. That is OK.

CPU for my laptop: x86_64, Intel Core i7 M620. Model 37.

According to wiki, AVX supports Intel CPU from Sandy Bridge in 2011. I bought my computer in 2010 so I guess not.

Could Ubuntu users please provide a step by step commands to install the stuffs mentioned in the origional post?

Given that I intend to use python3, when do I use pip and when to use pip3?

Daπid

unread,
Apr 4, 2018, 4:14:40 AM4/4/18
to peter cohen, Keras-users
pip2 : python2
pip3 : python3
pip : points to one of the two

So, if your pip points to pip3, go ahead and use whichever, otherwise use pip3. You can check with pip -V

And indeed, your CPU doesn't support AVX: https://ark.intel.com/products/43560/Intel-Core-i7-620M-Processor-4M-Cache-2_66-GHz

Mind you, this is fine to play around, but for anything half serious you'll need much more muscle than that.




The following should get you almost there, but mind you, I don't have access to an Ubuntu box to test it:



sudo apt-get install python3-pip python3-dev
sudo apt-get install build-essential cmake git unzip pkg-config libopenblas-dev liblapack-dev libhdf5-serial-dev graphviz
sudo apt-get build-dep python3-numpy python3-scipy python3-matplotlib python3-yaml python3-opencv python3-h5py


# Create and activate a virtual environment, you may need to apt-get install it

pip3 install numpy scipy matplotlib
pip3 install opencv-python h5py
pip3 install theano tensorflow pydot-ng keras


--
You received this message because you are subscribed to the Google Groups "Keras-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to keras-users+unsubscribe@googlegroups.com.

peter cohen

unread,
Apr 4, 2018, 8:13:16 AM4/4/18
to Keras-users
Thanks David.

The first two lines of commands went well. When I executed the 3rd line ( sudo apt-get build-dep python3-numpy ...) line, the system responded:

Reading package lists... Done
E: You must put some ‘source’ URIs in your source. list

Could you please let me know what to do?

I am using Ubuntu 17.10.1. It looks like python3, rather than 2, is installed on the system automatically by default. In Ubuntu 16.04.4, I had to install python3 manually as only python2 was installed by default.

peter cohen

unread,
Apr 5, 2018, 8:52:04 AM4/5/18
to Keras-users
Could ubuntu users please help?


2018年4月4日水曜日 8時13分16秒 UTC-4 peter cohen:

peter cohen

unread,
Apr 7, 2018, 9:13:28 AM4/7/18
to Keras-users

Hi David,

I took the risk and tried the command: software-properties-gtk
Then, under the "Ubuntu Software" tab click "Source code". After that, your 3rd and 4th lines of commands seem to have executed without issue.Don’t know why python2 appeared sometimes on the screen during command line execution.

When executing pip3 install opencv-python, should I type as written or change the word python to python3?

peter cohen

unread,
Apr 8, 2018, 8:40:52 AM4/8/18
to Keras-users
Hello,

After following the six steps David provided, what should I do next?

I think the last line of commands installed Keras already but I cannot find the examples folder mentioned in the origional post to try out the mnist_cnn.py example. Could anybody please help me to get started? Thank you.

peter cohen

unread,
Apr 8, 2018, 6:45:06 PM4/8/18
to Keras-users
To verify that I have installed keras, I did: pip3 show keras

The system responded:

Name: Keras
Version: 2.1.5
Summary: Deep leanning for humans
Home-page: https://github.com/keras-team/keras
:
:
Location: /home/Peter/.local/lib/python3.6/site-packages
Requires: pyyaml, shipyard, six, numpy


When I typed: python3 -c “import sys;print(sys.path)"

The system responded:

['' , '/user/lib/python36.zip', '/usr/lib/python3.6', '/user/lib/python3.6/lib-dynload', '/home/peter/.local/lib/python3.6/site-package', '/use/local/lib/python3.6/dist-packages', '/usr/lib/python3/dist-packages', '/use/lib/python3.6/dist-package']


Could you please let me know what to type next to get the examples folder to run the mnist_cnn.py example? Thanks
Reply all
Reply to author
Forward
0 new messages