0

tensorflow-gpu 1.4.0 + keras 2.1.1 on Ubuntu 16.04

Tensorflow 1.4.0 binary with CUDA 8 and cuDNN 6
Tensorflow 1.5.0 binary will be with CUDA 9 and cuDNN 7

The following procedure assumes that you use anaconda for python package manager.

  1. prepare for driver install
    1. Delete installed drivers by sudo apt purge nvidia*
    2. Press ctrl + alt + F1 and Login
    3. Stop X server by sudo service lightdm stop
    4. Disable the Nouveau kernel driver by creating a new file /etc/modprobe.d/blacklist-nouveau.conf
    5. The file contents is as follows

      blacklist nouveau
      blacklist lbm-nouveau
      options nouveau modeset=0
      alias nouveau off
      alias lbm-nouveau off
    6. Then, create another file by echo options nouveau modeset=0 | sudo tee -a /etc/modprobe.d/nouveau-kms.conf
    7. Update by sudo update-initramfs -u
    8. Then reboot by sudo reboot
  2. install driver
    1. Download the driver installer from here, say NVIDIA-***.run.
    2. Change the permission by sudo chmod +x NVIDIA-***.run
    3. Execute the installer by sudo ./NVIDIA-***.run
    4. Let’s confirm the installation by nvidia-smi
  3. install CUDA toolkit
    1. Download the toolkit installer from here, say cuda_***.run.
    2. Change the permission by sudo chmod +x cuda_***.run
    3. Install the toolkit by sudo ./cuda_***.run –toolkit –silent
    4. Install the samples by sudo ./cuda_***.run –samples –silent
    5. Add the following lines to the .bashrc

      export PATH="$PATH:/usr/local/cuda/bin"

      export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64"


      export CUDA_HOME=/usr/local/cuda

    6. Update by source ~/.bashrc
  4. install cuDNN
    1. Download packed file from here, say cudnn-***.tgz
    2. Untar the file by tar -xzvf cudnn-***.tgz
    3. Copy header and lib files by
      1. sudo cp cuda/lib64/* /usr/local/cuda/lib64/
      2. sudo cp cuda/include/cudnn.h /usr/local/cuda/include/

     

  5. install Tensorflow
    1. install by pip install tensorflow-gpu
  6. install Keras
    1. install by pip install keras
Advertisements
0

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.

0

cuda toolkit installation on Ubuntu 16.04 after upgrading from Ubuntu 14.04

This post explains how to upgrade cuda toolkit on ubuntu 16.04 after upgrading OS from ubuntu 14.04.

I got the following error when I tried to upgrade cuda toolkit from 7.5 to 8.0 by

sudo dpkg -i cuda-repo-ubuntu1604_8.0.44-1_amd64.deb

on terminal outputs the following error.

Selecting previously unselected package cuda-repo-ubuntu1604.
(Reading database ... 743925 files and directories currently installed.)
Preparing to unpack cuda-repo-ubuntu1604_8.0.44-1_amd64.deb ...
Unpacking cuda-repo-ubuntu1604 (8.0.44-1) ...
dpkg: error processing archive cuda-repo-ubuntu1604_8.0.44-1_amd64.deb (--install):
 trying to overwrite '/etc/apt/sources.list.d/cuda.list', which is also in package cuda-repo-ubuntu1404 8.0.44-1
Errors were encountered while processing:
 cuda-repo-ubuntu1604_8.0.44-1_amd64.deb

The above error indicates that there’s a conflict between the current cuda-related repository (for ubuntu 14.04) and the new upgrade (for ubuntu 16.04).

My solution was first remove the repository settings for ubuntu 14.04 by typing

sudo dpkg --purge cuda-repo-ubuntu1404

and then install the toolkit as

  1. sudo dpkg -i cuda-repo-ubuntu1604_8.0.44-1_amd64.deb
  2. sudo apt-get update
  3. sudo apt-get install cuda
0

unable to update cuda *** on Ubuntu 14.04

You may have GPG error (NO PUBKEY) related to nvidia’s cuda when you apt-get update like:
GPG error: http://developer.download.nvidia.com Release: The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY F60F4B3D7FA2AF80

The solution is to add public key to your system. In my case, the following command first downloads an appropriate pubkey file and then add the downloaded key to the system.

wget -qO – http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1404/x86_64/7fa2af80.pub | sudo apt-key add –

0

OpenCV 3.1.0 for Python2.7

 

  • PYTHON2_EXECUTABLE: /opt/anaconda/anaconda2/bin/python2.7
  • PYTHON2_INCLUDE_DIR: /opt/anaconda/anaconda2/include
  • PYTHON2_INCLUDE_DIR2:
  • PYTHON2_LIBRARY: /opt/anaconda/anaconda2/lib/libpython2.7.so
  • PYTHON2_LIBRARY_DEBUG:
  • PYTHON2_NUMPY_INCLUDE_DIRS: /opt/anaconda/anaconda2/lib/python2.7/site-packages/numpy/core/include
  • PYTHON2_PACKAGES_PATH: /opt/anaconda/anaconda2/lib/python2.7/site-packages