Skip to content

Instantly share code, notes, and snippets.

@Laurence-Cullen
Created December 28, 2020 16:40
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save Laurence-Cullen/1156168009b320cd391767ca9bf1ce9c to your computer and use it in GitHub Desktop.
Save Laurence-Cullen/1156168009b320cd391767ca9bf1ce9c to your computer and use it in GitHub Desktop.
Install CUDA for TensorFlow on Ubuntu 20.04
# Add NVIDIA package repositories
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin
sudo mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/7fa2af80.pub
sudo add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/ /"
sudo apt-get update
wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu2004/x86_64/nvidia-machine-learning-repo-ubuntu2004_1.0.0-1_amd64.deb
sudo apt install ./nvidia-machine-learning-repo-ubuntu2004_1.0.0-1_amd64.deb
sudo apt-get update
# Install NVIDIA driver
sudo apt-get install --no-install-recommends nvidia-driver-450
# Reboot. Check that GPUs are visible using the command: nvidia-smi
wget https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/libnvinfer7_7.1.3-1+cuda11.0_amd64.deb
sudo apt install ./libnvinfer7_7.1.3-1+cuda11.0_amd64.deb
sudo apt-get update
# Install development and runtime libraries (~4GB)
sudo apt-get install --no-install-recommends \
cuda-11-0 \
libcudnn8=8.0.4.30-1+cuda11.0 \
libcudnn8-dev=8.0.4.30-1+cuda11.0
# Install TensorRT. Requires that libcudnn8 is installed above.
sudo apt-get install -y --no-install-recommends libnvinfer7=7.1.3-1+cuda11.0 \
libnvinfer-dev=7.1.3-1+cuda11.0 \
libnvinfer-plugin7=7.1.3-1+cuda11.0
@Godofnothing
Copy link

These lines will not work :

sudo apt-get install --no-install-recommends \
    cuda-11-0 \
    libcudnn8=8.0.4.30-1+cuda11.0  \
    libcudnn8-dev=8.0.4.30-1+cuda11.0

They are actual for Ubuntu 18.04 https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/. Repo for Ubuntu 20.04 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/ provides only 8.0.5.39-1 version.

@gabriead
Copy link

This should work:
sudo apt-get install --no-install-recommends \ cuda-11-0 \ libcudnn8=8.0.5.39-1+cuda11.0 \ libcudnn8-dev=8.0.5.39-1+cuda11.0

@wangwendong1024
Copy link

Thank you for your help!

@knotgrass
Copy link

# Install TensorRT. Requires that libcudnn8 is installed above.
sudo apt-get install -y --no-install-recommends libnvinfer7=7.1.3-1+cuda11.0 \
    libnvinfer-dev=7.1.3-1+cuda11.0 \
    libnvinfer-plugin7=7.1.3-1+cuda11.0

Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Version '7.1.3-1+cuda11.0' for 'libnvinfer-dev' was not found
E: Unable to locate package libnvinfer-plugin7

I have some trouble with Line 29 - 31
i tried but It isn't work
sudo apt-get install -y --no-install-recommends libnvinfer8=8.0.0-1+cuda11.0 \ libnvinfer-dev=8.0.0-1+cuda11.0 \ libnvinfer-plugin8=8.0.0-1+cuda11.0_amd64.deb libnvinfer-plugin8_8.0.0-1+cuda11.0_amd64.deb

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