Install Nvidia CUDA-9.0 on Ubuntu 16.04 for Deep Learning

Friday, February 16, 2018

The latest version of CUDA is 9.1. However some deep learning frameworks are not yet ready for CUDA 9.1. The installation script of CUDA-9.1 is very similar to this one.

  • OS: Ubuntu 16.04 x86_64

  • (Optional) Uninstall old version CUDA Toolkit such as:

    sudo apt-get purge cuda
    sudo apt-get purge libcudnn6
    sudo apt-get purge libcudnn6-dev
  • Install CUDA Toolkit 9.0 and cuDNN 7.0 as follows:

    sudo dpkg -i cuda-repo-ubuntu1604_9.0.176-1_amd64.deb
    sudo dpkg -i libcudnn7_7.0.5.15-1+cuda9.0_amd64.deb
    sudo dpkg -i libcudnn7-dev_7.0.5.15-1+cuda9.0_amd64.deb
    sudo dpkg -i libnccl2_2.1.4-1+cuda9.0_amd64.deb
    sudo dpkg -i libnccl-dev_2.1.4-1+cuda9.0_amd64.deb
    sudo apt-get update
    sudo apt-get install cuda=9.0.176-1
    sudo apt-get install libcudnn7-dev
    sudo apt-get install libnccl-dev
  • Reboot the system to load the NVIDIA drivers.

  • Set up the development environment by modifying the PATH and LD_LIBRARY_PATH variables, also add them to the end of .bashrc file:

    export PATH=/usr/local/cuda-9.0/bin${PATH:+:${PATH}}
    export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}