Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save cobaohieu/1c3634a18d7b8a716bc98b5151ca050b to your computer and use it in GitHub Desktop.
Save cobaohieu/1c3634a18d7b8a716bc98b5151ca050b to your computer and use it in GitHub Desktop.
Installing CUDA 10.2, CuDNN 8.0.2, TensorRT 8.0.1, Ubuntu 18.04

Step 1: Installing CUDA (~5.5 minutes)

You can also install CUDA directly from the offline installer, but this is a little easier.

sudo apt update
sudo apt upgrade -y

mkdir install ; cd install
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin
sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
sudo add-apt-repository "deb http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/ /"
sudo apt-get update
sudo apt-get -y install cuda-10-2

Step 2: Installing CuDNN (~2 minutes)

Download CuDNN here (BOTH the runtime and dev, deb) from: https://developer.nvidia.com/rdp/cudnn-download

sudo dpkg -i libcudnn8_8.0.2.39-1+cuda10.2_amd64.deb
sudo dpkg -i libcudnn8-dev_8.0.2.39-1+cuda10.2_amd64.deb
sudo dpkg -i libcudnn8-doc_8.0.2.39-1+cuda10.2_amd64.deb

Verify installation

This method of installation installs cuda in /usr/include and /usr/lib/cuda/lib64, hence the file you need to look at is in /usr/include/cudnn.h.

cat /usr/include/x86_64-linux-gnu/cudnn_v*.h | grep CUDNN_MAJOR -A 2                                                         

Step 3: Installing TensorRT (~2 minutes)

Download TensorRT here. Use version 7.0.

sudo dpkg -i nv-tensorrt-repo-ubuntu1804-cuda10.2-trt7.0.0.11-ga-20191216_1-1_amd64.deb
sudo apt update
sudo apt install tensorrt libnvinfer8
sudo apt-get install -y libnvinfer8=8.0.1-1+cuda10.2
sudo apt-get install -y libnvonnxparsers8=8.0.1-1+cuda10.2
sudo apt-get install -y libnvparsers8=8.0.1-1+cuda10.2 
sudo apt-get install -y libnvinfer-plugin8=8.0.1-1+cuda10.2
sudo apt-get install -y libnvinfer-dev=8.0.1-1+cuda10.2
sudo apt-get install -y libnvonnxparsers-dev=8.0.1-1+cuda10.2
sudo apt-get install -y libnvparsers-dev=8.0.1-1+cuda10.2
sudo apt-get install -y libnvinfer-plugin-dev=8.0.1-1+cuda10.2
sudo apt-get install -y python-libnvinfer=8.0.1-1+cuda10.2
sudo apt-get install -y python3-libnvinfer=8.0.1-1+cuda10.2 

Step 3: Add to .bashrc

export CUDA_HOME=/usr/local/cuda
export DYLD_LIBRARY_PATH=$CUDA_HOME/lib64:$DYLD_LIBRARY_PATH
export PATH=$CUDA_HOME/bin:$PATH
export C_INCLUDE_PATH=$CUDA_HOME/include:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=$CUDA_HOME/include:$CPLUS_INCLUDE_PATH
export LD_LIBRARY_PATH=$CUDA_HOME/lib64:$LD_LIBRARY_PATH
export LD_RUN_PATH=$CUDA_HOME/lib64:$LD_RUN_PATH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment