Last active
July 11, 2017 20:51
-
-
Save aman95/fea1d872dcbeb81d0bd3e317deaf09be to your computer and use it in GitHub Desktop.
Nvidia cuda and cuDNN setup in Ubuntu 16.04
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Update Ubuntu apt cache | |
sudo apt update | |
# Update all Ubuntu packages | |
sudo apt upgrade | |
# Install build-essentials | |
sudo apt install build-essential | |
# Download cuda SDK 8 from Nvidia website (.run file) | |
# https://developer.nvidia.com/compute/cuda/8.0/Prod2/local_installers/cuda_8.0.61_375.26_linux-run | |
cd ~/Downloads | |
wget https://developer.nvidia.com/compute/cuda/8.0/Prod2/local_installers/cuda_8.0.61_375.26_linux-run | |
chmod +x cuda_8.0.61_375.26_linux.run | |
# Now we need to blacklist nouveau before installing the driver. | |
echo blacklist nouveau | sudo tee -a /etc/modprobe.d/blacklist-nouveau.conf | |
echo blacklist lbm-nouveau | sudo tee -a /etc/modprobe.d/blacklist-nouveau.conf | |
echo options nouveau modeset=0 | sudo tee -a /etc/modprobe.d/blacklist-nouveau.conf | |
echo alias nouveau off | sudo tee -a /etc/modprobe.d/blacklist-nouveau.conf | |
echo alias lbm-nouveau off | sudo tee -a /etc/modprobe.d/blacklist-nouveau.conf | |
echo options nouveau modeset=0 | sudo tee -a /etc/modprobe.d/nouveau-kms.conf | |
# Update kernel and initrd | |
sudo update-initramfs -u | |
# Reboot now | |
# At Login screen goto tty mode by pressing Ctrl+Alt+F1 | |
# Enter credentials and login | |
# Now we need to stop lightdm | |
sudo service lightdm stop | |
# cd to Downloads folder and execute .run file | |
cd ~/Downloads | |
sudo bash cuda_8.0.61_375.26_linux.run --no-opengl-libs | |
# Remember --no-opengl-libs flag is very important, else it may result into login loop | |
# During the install: | |
# Accept EULA conditions | |
# Say YES to installing the NVIDIA driver | |
# SAY YES to installing CUDA Toolkit + Driver | |
# Say YES to installing CUDA Samples | |
# Say NO rebuilding any Xserver configurations with Nvidia. | |
# If in lsmod nvidia is not present | |
sudo modprobe nvidia | |
# Set Environment path variables in bashrc | |
echo 'export PATH=/usr/local/cuda-8.0/bin/:$PATH' | tee -a ~/.bashrc | |
echo 'export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64:$LD_LIBRARY_PATH' | tee -a ~/.bashrc | |
echo 'export CUDA_HOME=/usr/local/cuda-8.0' | tee -a ~/.bashrc | |
echo 'export CUDA_ROOT=/usr/local/cuda-8.0' | tee -a ~/.bashrc | |
echo 'export LIBRARY_PATH=/usr/local/cuda/lib64' | tee -a ~/.bashrc | |
source ~/.bashrc | |
# Check CUDA driver version: | |
nvcc -V | |
# At this point you can start lightdm and login to Ubuntu via gui | |
sudo service lightdm start | |
# Download cuDNN v5.1 from nvidia website | |
# https://developer.nvidia.com/cudnn | |
# Extract cudnn-8.0-linux-x64-v5.1.tgz you will get a folder "cuda" | |
cd ~/Downloads/ | |
sudo cp cuda/include/cudnn.h /usr/local/cuda/include | |
sudo cp cuda/lib64/* /usr/local/cuda/lib64 | |
sudo chmod a+r /usr/local/cuda/lib64/libcudnn* | |
# At this point cuda and cuDNN installation is complete. | |
# Go ahead and test it using cuda samples or running any gpu based ML project | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment