When I launch import keras in a Jupyter Notebook cell, it crashes with a message. The kernel appears to have died. It will restart automatically.

Keras 2.2.0

jupyter 1.0.0
jupyter-client 5.2.3
jupyter-console 5.2.0
jupyter-core 4.4.0
jupyterlab 0.32.1
jupyterlab-launcher 0.10.5

Python 3.6.6

Console output

 kraamis@debian [~]$ python3 Python 3.6.6 (default, Jun 27 2018, 14:44:17) [GCC 8.1.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import keras /usr/lib/python3/dist-packages/h5py/__init__.py:36: 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. Недопустимая инструкция 
  • Just try to import in the Python console, what will happen? - insolor
  • Added console output to post - Andrey Evdokimov
  • After the message "Invalid instruction" in bash throws out? Assumption: the installed version of Tensorflow does not match the bit depth of the system. - insolor
  • No, the thing was that my processor is old and the new versions of libraries do not support. - Andrey Evdokimov

1 answer 1

Heavyweights like TensorFlow, Keras, etc. better to install in VirtualEnv , and not in the system Python.

Steps to create VirtualEnv:

Install Anaconda:

 bash Anaconda3-XXX-Linux-x86_64.sh 

Conda update:

 conda update conda 

Creating your own VirtualEnv (environment name - ml [machine learning], Python version - 3.6):

 conda create -n ml python=3.6 \ anaconda ipython jupyter cython matplotlib scikit-learn openpyxl pyarrow \ lxml beautifulsoup4 html5lib sqlalchemy pymysql psycopg2 fastparquet \ pandas-datareader opencv nltk xlrd xlwt xlsxwriter networkx pyodbc gensim 

Install modules from the conda-forge repository:

 conda install -n ml -c conda-forge scikit-image keras 

PS If you suddenly break something in VirtualEnv - you can always recreate it without affecting the system Python. Better yet, clone your working VirtualEnv and test new versions of modules in it:

 conda create --name ml --clone ml_test conda update --all -n ml_test -y