Skip to content

Instantly share code, notes, and snippets.

@bryanlimy
Last active March 12, 2020 16:21
Show Gist options
  • Save bryanlimy/baaac3f603001b20a705182d40c42b5e to your computer and use it in GitHub Desktop.
Save bryanlimy/baaac3f603001b20a705182d40c42b5e to your computer and use it in GitHub Desktop.
Install Nvidia Driver, CUDA 9.0 and cuDNN 7.2 on Ubuntu 18.04 laptops

This README demonstrate how to install Nvidia driver, CUDA 9.0, cuDNN 7.2 on Ubuntu 18.04 computer with iGPU and Nvidia GPU. Using the following installation --flags, X Server is going to be running on the iGPU so that the dGPU can be used for CUDA tasks.

  1. Install required packages
sudo apt install build-essential libxml2 gcc-multilib dkms gcc-6 g++6 freeglut3-dev libx11-dev libxmu-dev libxi-dev libglu1-mesa libglu1-mesa-dev
  1. Add the following to /etc/modprobe.d/blacklist-nouveau.conf to disable nouveau
blacklist nouveau
options nouveau modeset=0
  1. Run
sudo update-initramfs -u
  1. Reboot

  2. Stop Desktop Manager

sudo telinit 3
  1. Install Nvidia Driver with --no-opengl-files --dkms --no-drm flags
sudo sh NVIDIA-Linux-x86_64-390.77.run --no-opengl-files --dkms --no-drm
  1. Reboot

  2. Comment/delete lines in /etc/modprobe.d/blacklist-nvidia-conf

# blacklist nvidia
blacklist nvidia-drm
# blacklist nvidia-modeset
# alias nvidia off
alias nvidia-drm off
# alias nvidia-modeset off
  1. Reboot

  2. Install CUDA 9 with --override flag

sudo sh cuda_9.0.176_384.81_linux.run --override

(OPTIONAL) install related patches if desire

  1. Add PATH to ~/.bashrc and/or ~/.zshrc
export PATH=${PATH}:/usr/local/cuda/bin
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/cuda/lib64
  1. Download and extract cuDNN 7.2.1
tar -xvf cudnn-9.0-linux-x64-v7.2.1.38.tgz
  1. Copy cuDNN file to /usr/local/cuda
sudo cp cuda/include/cudnn.h /usr/local/cuda/include
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment