Skip to content

Instantly share code, notes, and snippets.

@mjdietzx
Last active October 14, 2024 12:19
Show Gist options
  • Save mjdietzx/0ff77af5ae60622ce6ed8c4d9b419f45 to your computer and use it in GitHub Desktop.
Save mjdietzx/0ff77af5ae60622ce6ed8c4d9b419f45 to your computer and use it in GitHub Desktop.
Install CUDA Toolkit v8.0 and cuDNN v6.0 on Ubuntu 16.04
#!/bin/bash
# install CUDA Toolkit v8.0
# instructions from https://developer.nvidia.com/cuda-downloads (linux -> x86_64 -> Ubuntu -> 16.04 -> deb (network))
CUDA_REPO_PKG="cuda-repo-ubuntu1604_8.0.61-1_amd64.deb"
wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/${CUDA_REPO_PKG}
sudo dpkg -i ${CUDA_REPO_PKG}
sudo apt-get update
sudo apt-get -y install cuda
# install cuDNN v6.0
CUDNN_TAR_FILE="cudnn-8.0-linux-x64-v6.0.tgz"
wget http://developer.download.nvidia.com/compute/redist/cudnn/v6.0/${CUDNN_TAR_FILE}
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}}
@EICT321
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?

@Mahedi-61
Copy link

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

@washcycle
Copy link

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

@kitovyj
Copy link

kitovyj commented Dec 26, 2017

Cuda 9.0 is installed instead of 8.0

@blaine12100
Copy link

I have tried to add the LD_LIBRARY_PATH as instructed and i am still getting the 'libcudnn.so.6: 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

@srhrshr
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.

Thanks!

@wyfSunflower
Copy link

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

@pbertsch
Copy link

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

@JohnAllen
Copy link

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

@anujonthemove
Copy link

If you are still facing installation issues, try out this guide: https://medium.com/@anujonthemove/deep-learning-environment-setup-on-ubuntu-16-04-83078e1cba1f

@prameshbajra
Copy link

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?

@jrichardsz
Copy link

4040 error on ubuntu 20

--2022-01-23 17:43:34--  http://developer.download.nvidia.com/compute/redist/cudnn/v6.0/cudnn-8.1-linux-x64-v6.0.tgz
Resolving developer.download.nvidia.com (developer.download.nvidia.com)... 152.199.20.126
Connecting to developer.download.nvidia.com (developer.download.nvidia.com)|152.199.20.126|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://developer.download.nvidia.com/compute/redist/cudnn/v6.0/cudnn-8.1-linux-x64-v6.0.tgz [following]
--2022-01-23 17:43:34--  https://developer.download.nvidia.com/compute/redist/cudnn/v6.0/cudnn-8.1-linux-x64-v6.0.tgz
Connecting to developer.download.nvidia.com (developer.download.nvidia.com)|152.199.20.126|: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