Installing CUDA Toolkit and CuDNN on Ubuntu

Before You Start

Verify GPU and stuff.

$ lspci | grep -i nvidia
$ uname -m && cat /etc/*release
$ gcc --version

Installing CUDA

Make sure you download the correct version.  I am using Ubuntu 16, so I need CUDA 8.  I made the mistake of downloading CUDA 7.5, which is only compatible with Ubuntu 14 and 15.

Dowload from NVIDIA:

As of the time of this post, the installation instruction on the download page has a typo in it.  The file name has a “-deb” instead of “.deb“.

$ sudo dpkg -i cuda-repo-ubuntu1604-8-0-rc_8.0.27-1_amd64.deb
$ sudo apt-get update
$ sudo apt-get install cuda

After installing we will need to add the path.

$ export PATH=/usr/local/cuda-8.0/bin:$PATH
$ export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64:$LD_LIBRARY_PATH

Verify the driver.

$ cat /proc/driver/nvidia/version

NVRM version: NVIDIA UNIX x86_64 Kernel Module 361.62 Tue May 24 20:21:31 PDT 2016
GCC version: gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.1)

Check compiler.

$ nvcc -V

The program 'nvcc' is currently not installed. You can install it by typing:
sudo apt install nvidia-cuda-toolkit

$ sudo apt install nvidia-cuda-toolkit

If the compiler was not install, install it now.  The result should look something like this.

$ nvcc -V

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2015 NVIDIA Corporation
Built on Tue_Aug_11_14:27:32_CDT_2015
Cuda compilation tools, release 7.5, V7.5.17

At this point, you’re supposed to run the samples in order to test if everything is working properly.  I was never able to install the samples, but I was able to get Tensorflow and Torch to run using the GPU.  So, in the end, everything worked out fine.

Installing CuDNN


This is easy. All you have to do is uncompressed a folder and then copy and paste the files to the correct locations.

$ sudo cp include/cudnn.h /usr/local/cuda/include
$ sudo cp lib64/libcudnn* /usr/local/cuda/lib64
$ sudo chmod a+r /usr/local/cuda/lib64/libcudnn*



links and tutorials:


One thought on “Installing CUDA Toolkit and CuDNN on Ubuntu

  • January 7, 2017 at 6:24 PM

    Thanks buddy! A big help!

    Please could you explain the commands a bit more in detail. Many of us are really new to Linux.


Leave a Reply

Your email address will not be published. Required fields are marked *

CommentLuv badge