Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Install CUDA Toolkit v8.0 and cuDNN v6.0 on Ubuntu 16.04
# install CUDA Toolkit v8.0
# instructions from (linux -> x86_64 -> Ubuntu -> 16.04 -> deb (network))
sudo dpkg -i ${CUDA_REPO_PKG}
sudo apt-get update
sudo apt-get -y install cuda
# install cuDNN v6.0
tar -xzvf ${CUDNN_TAR_FILE}
sudo cp -P cuda/include/cudnn.h /usr/local/cuda-8.0/include
sudo cp -P cuda/lib64/libcudnn* /usr/local/cuda-8.0/lib64/
sudo chmod a+r /usr/local/cuda-8.0/lib64/libcudnn*
# set environment variables
export PATH=/usr/local/cuda-8.0/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64\${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
Copy link

ytakashina commented Jun 3, 2017

I found the following line contains an unnecessary backslash, which causes errors on some libraries. (e.g., tensorflow)

export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64\${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

Copy link

AashishV commented Jun 7, 2017

@y-takashina Do you know what is correct path? Because I am also getting the errors in tensorflow

Copy link

ytakashina commented Jun 8, 2017

Removing the backslash worked for me.
You can confirm your operating system recognizes the correct path by checking $LD_LIBRARY_PATH.


Copy link

clintonyeb commented Aug 22, 2017

The backslash is used in the documentation to show continuation of the command

export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib\

is same as this on the same line without the backslash:

export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

Copy link

luizhenriquesoares commented Oct 3, 2017

Copy link

luizhenriquesoares commented Oct 3, 2017

Copy link

Ricocotam commented Oct 29, 2017

Now Cuda 9.0 is installed, you have to specify the version to apt. If you don't, cuda9 is installed :

sudo apt-get install cuda-8-0

I get it from here.

Copy link

kenshiro-o commented Nov 5, 2017

Thanks for the gist! Definitely saved my Tensorflow life today...
My paths were already well set but after I tried to echo your suggested LD_LIBRARY_PATH, I realised I had extra }} in it (maybe caused by the backwards slash?). Just using the following should suffice:

export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

Copy link

EICT321 commented Nov 6, 2017

i have installed cuda 9.0 and operating system is centos 7. I just want to know which version of tensor flow will support cuda 9 and centos 7. Also please let me know which version of cudnn should I install?

Copy link

Mahedi-61 commented Nov 30, 2017

At last i found a resource that really works. Thanks for this. Please remove the unnecessary backslash from last line.

Copy link

washcycle commented Dec 6, 2017

@EICT321 You might be moving too fast... it might work, but I don't think they official support 9 yet. list tensorflow versions and their tested configurations.

Copy link

kitovyj commented Dec 26, 2017

Cuda 9.0 is installed instead of 8.0

Copy link

blaine12100 commented Jan 2, 2018

I have tried to add the LD_LIBRARY_PATH as instructed and i am still getting the ' cannot open shared object file: No such file or directory' error.This is a screenshot of my ~./bashrc file and Nvidia-smi screenshot.

Do let me know if there is anything else i need to try.
screenshot from 2018-01-02 21-06-00
bashrc screenshot

Copy link

srhrshr commented Jan 11, 2018

In case running nvidia-smi throws the following error, just try rebooting. That seemed to work for me.
NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running

This script works by the way! Ubuntu 16.04.3 represent here. I successfully installed Cuda 8.0 and cuDNN 6.0, without running into any problems with the display/graphics like I usually used to. I highly recommend using the package manager installation over the runfile method.


Copy link

wyfSunflower commented Jan 12, 2018

This script is not suitable for default graphic card is not nvidia card, such as " dell precision tower 7910", after I run this script and reboot ubuntu, system could not login. And now tensorflow can only support cuda8, but this script will install cuda9.1

Copy link

pbertsch commented Feb 25, 2018

For Ubuntu 16.04 users only:

change the the following line in the script
sudo apt-get -y install cuda to sudo apt-get -y install cuda-8-0

Copy link

JohnAllen commented Jan 30, 2019

GPU TensorFlow now requires cudnn 9.0. Anyone have an updated link for 9.0?

Copy link

anujonthemove commented Feb 13, 2019

If you are still facing installation issues, try out this guide:

Copy link

prameshbajra commented Apr 3, 2019

GPU TensorFlow now requires cudnn 9.0. Anyone have an updated link for 9.0?

@JohnAllen Did you find a updated script for GPU tensorflow?

Copy link

jrichardsz commented Jan 23, 2022

4040 error on ubuntu 20

--2022-01-23 17:43:34--
Resolving (
Connecting to (||:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: [following]
--2022-01-23 17:43:34--
Connecting to (||:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2022-01-23 17:43:35 ERROR 404: Not Found.

tar (child): cudnn-8.1-linux-x64-v6.0.tgz: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
cp: cannot stat 'cuda/include/cudnn.h': No such file or directory
cp: cannot stat 'cuda/lib64/libcudnn*': No such file or directory
chmod: cannot access '/usr/local/cuda-8.0/lib64/libcudnn*': No such file or directory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment