Installation Notes for Tensorrt, Cuda, Cudnn, Anaconda, Pytorch, Tensorflow, Torch2trt in Ubuntu 18.04
- Install nvidia driver 450
- Install cuda-10.2 and cudnn 8.0.5
- Install Anaconda and Create Environment
- Install TensorRT-7.2.3
- Install Torch2trt
Run below command to install nvidia driver
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update
# exact version 450.102.04
sudo apt-get install nvidia-driver-450
Then reboot and check the nvidia driver
init 6
nvidia-smi
-
Download cuda toolkit 10.2 deb file from nivida developer website
-
Then run below commands to install cuda 10.2.
cd (cuda download directory)
sudo dpkg -i cuda-repo-ubuntu1804-10-2-local-10.2.89-440.33.01_1.0-1_amd64.deb
sudo apt-key add /var/cuda-repo-10-2-local-10.2.89-440.33.01/7fa2af80.pub
sudo apt-get update
sudo apt-get -y install cuda
- Then add these cuda environment variables in
~/.bashrc
file.
nano ~/.bashrc
# add these variables in the bottom of ~/.bashrc file
export PATH=/usr/local/cuda-10.2/bin:/usr/local/cuda-10.2/NsightCompute-2019.1${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-10.2/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
- Then activate these variable with this command
source ~/.bashrc
- Downloads cudnn 8.0.5 deb files for cuda 10.2 from nvidia developer website
- Run these command to install cudnn 8.0.5
sudo dpkg -i libcudnn8_8.0.5.39-1+cuda10.2_amd64.deb
sudo dpkg -i libcudnn8-dev_8.0.5.39-1+cuda10.2_amd64.deb
sudo dpkg -i libcudnn8-samples_8.0.5.39-1+cuda10.2_amd64.deb
- Download and install anaconda
- Then create virtual environment
conda create -n dev python=3.7
- Install pytorch 1.7.1
conda activate dev
pip install torch==1.7.1 torchvision==0.8.2 torchaudio==0.7.2
python -c "import torch; print('Cuda:', torch.cuda.is_available())"
- Install tensorflow-gpu
conda activate dev
conda install tensorflow-gpu=2.2.0
python -c "import tensorflow as tf; print('Cuda:', tf.test.is_gpu_available())"
-Install other python computer vision packages
pip install Cython
pip install pycocotools
pip install -r ~/requirements.txt
- Download TensorRT
7.2.3
tar file for cuda 10.2 and cudnn8.1.
# extract tensorrt tar file
tar xzvf <downloaded TensorRT tar file>
Note* You can check official tensorrt installation instruction from here.
- Then add these tensorrt environment variables in
~/.bashrc
file.
nano ~/.bashrc
# change your tensorrt extracted folder path
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:<your tensorrt extracted folder>/lib
export PATH=$PATH:<your tensorrt extracted folder>/bin
- Then activate these variables with this command
source ~/.bashrc
- Install python packages from your tenssorrt extracted folder.
cd <your tensorrt extracted folder>
pip install python/tensorrt-7.1.3.4-cp<your python version>.whl
pip install graphsurgeon/*.whl
pip install uff/*.whl
- Install Torch2trt
sudo apt-get install libprotobuf* protobuf-compiler ninja-build
git clone https://github.com/NVIDIA-AI-IOT/torch2trt.git
cd Torch2trt
python setup.py install --plugins
Bravo!!! ENJOY your deep learning journey.