How to Install TensorRT on Ubuntu 18.04

Daniel Vadranapu
3 min readNov 11, 2020

Requirements for TensorRT

  • Ubuntu 18.04 with GPU which has Tensor Cores. Currently, there is no support for Ubuntu 20.04 with TensorRT.
  • Nvidia driver installed on the system preferably NVIDIA-418.
  • Cuda 10.0 or above is required.

Installing Cuda 10.0

sudo dpkg -i cuda-repo-ubuntu1804–10–0-local-10.0.130–410.48_1.0–1_amd64.deb
sudo apt-key add /cuda-repo-10–0-local-10.0.130.410.48/7fa2af80.pub
sudo apt-get update
sudo apt-get install cuda
  • This will install the Cuda driver in your system.
  • After installation please add the following lines.
sudo bash -c "echo /usr/local/cuda-10.0/lib64/ > /etc/ld.so.conf.d/cuda-10.0.conf"
sudo ldconfig
  • Finally, replace the below line in the file sudo nano /etc/environment
PATH=”/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin”PATH=”/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local/cuda/bin”
  • This will enable us to see which version of Cuda is been installed.
  • nvcc -V this should display the below information.
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2018 NVIDIA Corporation
Built on Sat_Aug_25_21:08:01_CDT_2018
Cuda compilation tools, release 10.0, V10.0.130

TensorRT Installation

  • Download the TensorRT .deb file from the below link

https://developer.nvidia.com/compute/machine-learning/tensorrt/secure/6.0/GA_6.0.1.5/local_repos/nv-tensorrt-repo-ubuntu1804-cuda10.0-trt6.0.1.5-ga-20190913_1-1_amd64.deb

Login to nvidia website
Login with Facebook for downloading TensorRT.
Select TensorRT 6
Download TensorRT 6.0.1.5 for Ubuntu 18.04.

Install TensorRT via the following commands.

sudo dpkg -i nv-tensorrt-repo-ubuntu1804-cuda10.0-trt6.0.1.5-ga-20190913_1-1_amd64
sudo apt-key add /var/nv-tensorrt-repo-ubuntu1804-cuda10.0-trt6.0.1.5-ga-20190913_1-1_amd64/7fa2af80.pub
sudo apt-get update
sudo apt-get install tensorrt
# this is for python2 installation
sudo apt-get install python-libnvinfer-dev
#this is for python3 installationsudo apt-get install python3-libnvinfer-devsudo apt-get install uff-converter-tf
sudo apt-get install onnx-graphsurgeon
dpkg -l | grep TensorRT

You should see something similar to this.

ii  graphsurgeon-tf 7.2.1-1+cuda10.0 amd64 GraphSurgeon for TensorRT package
ii libnvinfer-bin 7.2.1-1+cuda10.0 amd64 TensorRT binaries
ii libnvinfer-dev 7.2.1-1+cuda10.0 amd64 TensorRT development libraries and headers
ii libnvinfer-doc 7.2.1-1+cuda10.0 all TensorRT documentation
ii libnvinfer-plugin-dev 7.2.1-1+cuda10.0 amd64 TensorRT plugin libraries
ii libnvinfer-plugin7 7.2.1-1+cuda10.0 amd64 TensorRT plugin libraries
ii libnvinfer-samples 7.2.1-1+cuda10.0 all TensorRT samples
ii libnvinfer7 7.2.1-1+cuda10.0 amd64 TensorRT runtime libraries
ii libnvonnxparsers-dev 7.2.1-1+cuda10.0 amd64 TensorRT ONNX libraries
ii libnvonnxparsers7 7.2.1-1+cuda10.0 amd64 TensorRT ONNX libraries
ii libnvparsers-dev 7.2.1-1+cuda10.0 amd64 TensorRT parsers libraries
ii libnvparsers7 7.2.1-1+cuda10.0 amd64 TensorRT parsers libraries
ii python-libnvinfer 7.2.1-1+cuda10.0 amd64 Python bindings for TensorRT
ii python-libnvinfer-dev 7.2.1-1+cuda10.0 amd64 Python development package for TensorRT
ii python3-libnvinfer 7.2.1-1+cuda10.0 amd64 Python 3 bindings for TensorRT
ii python3-libnvinfer-dev 7.2.1-1+cuda10.0 amd64 Python 3 development package for TensorRT
ii tensorrt 7.2.1.x-1+cuda10.0 amd64 Meta package of TensorRT
ii uff-converter-tf 7.2.1-1+cuda10.0 amd64 UFF converter for TensorRT package
ii onnx-graphsurgeon 7.2.1-1+cuda10.0 amd64 ONNX GraphSurgeon for TensorRT package

Note: This process works for all Cuda drivers (10.1, 10.2)

--

--