Skip to content

Instantly share code, notes, and snippets.

@dbousamra
Created February 19, 2019 02:12
Show Gist options
  • Save dbousamra/a0b4860c74f306f7c04eed88330c9c10 to your computer and use it in GitHub Desktop.
Save dbousamra/a0b4860c74f306f7c04eed88330c9c10 to your computer and use it in GitHub Desktop.
#!/bin/bash
## This gist contains step by step instructions to install cuda v9.0 and cudnn 7.2 in ubuntu 18.04
### steps ####
# verify the system has a cuda-capable gpu
# download and install the nvidia cuda toolkit and cudnn
# setup environmental variables
# verify the installation
###
### to verify your gpu is cuda enable check
lspci | grep -i nvidia
### gcc compiler is required for development using the cuda toolkit. to verify the version of gcc install enter
gcc --version
# first get the PPA repository driver
sudo add-apt-repository ppa:graphics-drivers/ppa
# install nvidia driver
sudo apt install nvidia-384 nvidia-384-dev
# install other import packages
sudo apt-get install g++ freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libglu1-mesa libglu1-mesa-dev
# CUDA 9 requires gcc 6
sudo apt install gcc-6
sudo apt install g++-6
# downoad one of the "runfile (local)" installation packages from cuda toolkit archive and all patches
wget https://developer.nvidia.com/compute/cuda/9.0/Prod/local_installers/cuda_9.0.176_384.81_linux-run
wget https://developer.nvidia.com/compute/cuda/9.0/Prod/patches/1/cuda_9.0.176.1_linux-run
wget https://developer.nvidia.com/compute/cuda/9.0/Prod/patches/2/cuda_9.0.176.2_linux-run
wget https://developer.nvidia.com/compute/cuda/9.0/Prod/patches/3/cuda_9.0.176.3_linux-run
wget https://developer.nvidia.com/compute/cuda/9.0/Prod/patches/4/cuda_9.0.176.4_linux-run
# make the download files executable
chmod +x cuda_9.0.176_384.81_linux-run
chmod +x cuda_9.0.176.1_linux-run
chmod +x cuda_9.0.176.2_linux-run
chmod +x cuda_9.0.176.3_linux-run
chmod +x cuda_9.0.176.4_linux-run
# execute the main installer
sudo ./cuda_9.0.176_384.81_linux-run --override
# answer following questions while installation begin
# You are attempting to install on an unsupported configuration. Do you wish to continue? y
# Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 384.81? n
# Install the CUDA 9.0 Toolkit? y
# set up symlinks for gcc/g++
sudo ln -s /usr/bin/gcc-6 /usr/local/cuda/bin/gcc
sudo ln -s /usr/bin/g++-6 /usr/local/cuda/bin/g++
# setup your paths
echo 'export PATH=/usr/local/cuda-9.0/bin:$PATH' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc
source ~/.bashrc
# install CUDA patches
sudo ./cuda_9.0.176.1_linux-run
sudo ./cuda_9.0.176.2_linux-run
sudo ./cuda_9.0.176.3_linux-run
sudo ./cuda_9.0.176.4_linux-run
# install cuDNN v7.0.5
CUDNN_TAR_FILE="cudnn-9.0-linux-x64-v7.tgz"
wget https://s3.amazonaws.com/ava-engine-releases/nvidia/${CUDNN_TAR_FILE}
tar -xzvf ${CUDNN_TAR_FILE}
# copy the following files into the cuda toolkit directory.
sudo cp -P cuda/include/cudnn.h /usr/local/cuda-9.0/include
sudo cp -P cuda/lib64/libcudnn* /usr/local/cuda-9.0/lib64/
sudo chmod a+r /usr/local/cuda-9.0/lib64/libcudnn*
# finally, to verify the installation, check
nvidia-smi
nvcc -V
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment