Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
How to install CUDA toolkit 11 at ubuntu 20.04

Step by step instruction how to install CUDA 11 (11.1 11.2) Ubuntu 20.04

At the time of writing (26.04.2021) Official Ubuntu 20.04 repositories contains only CUDA 10.1 toolkit. If you run command: sudo apt install nvidia-cuda-toolkit you will get only CUDA 10.1 :(

NVidia Ubuntu 20.04 repository for CUDA 11

If you need CUDA Tolkit 11 with nvcc, other tools and libraries you can install it from NVIDIA Ubunutu 20.04 repository.

Add Ubuntu 20.04 repository

sudo mv /etc/apt/preferences.d/cuda-repository-pin-600
sudo apt-key adv --fetch-keys
sudo add-apt-repository "deb /"

Install cuda toolkit

Update and install cuda toolkit, you will gain access to many version of cuda and cuda toolkit.

Write apt install cuda-toolkit and press tab it will show list of all available versions (11.1,11.2,11.3 at the time of writing)

sudo apt update
sudo apt install cuda-toolkit-11.1

Install cuDNN

Download cuDNN from NVidia. You'll have to log in, answer a few questions then you will be redirected to download. Find the right cuDNN binary packages and save it on you computer.

tar -xzvf cudnn-11.2-linux-x64-v8.1.1.33.tgz

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*

Add CUDA_HOME to PATH environmet

Edit /home/$USER/.bashrc file

export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64"
export CUDA_HOME=/usr/local/cuda
export PATH="/usr/local/cuda/:$PATH

Disable Sleep on Ubuntu Server

New drivers automatically install some xorg server packages and it activates power management options. Probably on your server you want to disable power management (sleep, hibernate).

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