-
Notifications
You must be signed in to change notification settings - Fork 34
Installation
Warning
Keras with MXNet backend is still in experimental Alpha phase. You can view the detailed list of known issues and unsupported functionalities in the release notes here.
Steps involved
- Install Keras dependencies - Numpy, Nose, TensorFlow and Theano (TensorFlow and Theano are required for running tests)
- Install CUDA and cuDNN - This is required only if you are installing on a GPU machine.
- Install Keras from source - https://github.com/dmlc/keras
- Install MXNet from source - https://github.com/dmlc/mxnet
Note:
The following installation instructions are tested on Ubuntu 14.04/16.04 and Mac OS EL Capitan and Sierra.
You need to install pip if not already installed. Then, follow the below installation commands to install Keras dependencies.
$ pip install numpy
$ pip install nose
$ pip install nose-parameterized
$ pip install Theano
# Refer https://www.tensorflow.org/install/ for more detailed Tensorflow installation instructions.
$ pip install tensorflow # For CPU machines
OR
$ pip install tensorflow-gpu # For GPU machines
Note:
Skip to step 1.3 if you are setting up a CPU machine.
Install the following NVIDIA libraries to setup with GPU support:
- Install CUDA 8.0 following the NVIDIA's installation guide.
- Install cuDNN 5 for CUDA 8.0 following the NVIDIA's installation guide. You may need to register with NVIDIA for downloading the cuDNN library.
Note: Make sure to add CUDA install path to LD_LIBRARY_PATH
.
For Example on Ubuntu machine, if you have downloaded CUDA debian package (cuda-repo-ubuntu1604_8.0.61-1_amd64.deb
) and cuDNN 5.1 library (cudnn-8.0-linux-x64-v5.1.tgz
), below are set of commands you run to setup CUDA and cuDNN.
# Setup CUDA 8.0.
$ sudo apt-get update
$ sudo apt-get install build-essential
$ sudo apt-get install linux-headers-$(uname -r)
# Assuming you have downloaded CUDA deb package from https://developer.nvidia.com/cuda-downloads
$ sudo dpkg -i cuda-repo-ubuntu1604_8.0.61-1_amd64.deb
$ sudo apt-get update
$ sudo apt-get install cuda
$ export CUDA_HOME=/usr/local/cuda-8.0
$ PATH=${CUDA_HOME}/bin:${PATH}
$ export PATH
$ export LD_LIBRARY_PATH=/usr/local/cuda/lib64/:$LD_LIBRARY_PATH
# Setup cuDNN 5.1 for CUDA 8.0.
# Assuming you have registered with NVIDA and downloaded cuDNN 5.1 for CUDA 8 from https://developer.nvidia.com/cudnn
$ tar -xvzf cudnn-8.0-linux-x64-v5.1.tgz
$ sudo cp cuda/include/cudnn.h /usr/local/cuda/include/
$ sudo cp cuda/lib64/* /usr/local/cuda/lib64/
You can verify your CUDA setup with following commands.
$ nvcc --version
$ nvidia-smi
# Clone keras repo to ~/keras directory
$ git clone https://github.com/dmlc/keras.git ~/keras --recursive
# Install Keras
$ cd ~/keras
$ sudo python setup.py install
Note
You need to install MXNet from latest source code to get Keras working with MXNet backend.
Go to MXNet Installation guide, choose "Linux or MacOS", choose "Python", choose "CPU or GPU", choose "Build from Source" and follow the installation guide to build and install MXNet with Python bindings.
You should set Keras backend to 'mxnet' to run your Keras code with MXNet backend. You can either set the environment variable or edit the keras config file.
Option 1
Set the environment variable
$ export KERAS_BACKEND=mxnet
Option 2
Edit the keras config file
Open "~/.keras/keras.json" file and set "backend=mxnet".
You can validate the installation by trying to import Keras in Python terminal and verifying that Keras is using mxnet backend.
$ python
>>> import keras as k
Using mxnet backend