keras installation on ubuntu 16.04 with CUDA and cuDNN

  1. install CUDA
    download cuda-repo-ubuntu1604_8.0.44-1_amd64.deb from here

    1. sudo dpkg -i cuda-repo-ubuntu1604_8.0.44-1_amd64.deb
    2. sudo apt-get update
    3. sudo apt-get cuda
  2. update path settings
    add the following lines at the end of ~/.bashrc and type “source ~/.bashrc” on terminal.

    1. # for CUDA and cuDNN
    2. export PATH=/usr/local/cuda-8.0/bin:$PATH
    3. export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64:$LD_LIBRARY_PATH
  3. install cuDNN
    download cuDNN package from here

    1. tar xzvf cudnn-8.0-linux-x64-v5.1.tgz
    2. sudo cp -a cuda/lib64/* /usr/local/cuda-8.0/lib64/
    3. sudo cp -a cuda/include/* /usr/local/cuda-8.0/include/
    4. sudo ldconfig
  4. install theano
    pip install –upgrade –no-deps git+https://github.com/Theano/Theano.git

    1. create ~/.theanorc and write down the following lines
      [global]device = gpu
      floatX = float32

      [nvcc]
      flags=-D_FORCE_INLINES

      [cuda]
      root = /usr/local/cuda-8.0

  5. install keras
    pip install –upgrade –no-deps git+https://github.com/fchollet/keras.git

If python outputs any tensorflow-related warning, edit backend information in ~/.keras/keras.json from tensorflow to theano.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s