Problems installing TensorRT in docker container

Problems installing TensorRT in docker container

Uninstall the installed version on Ubuntu:

   sudo apt-get purge "libnvinfer*"

If you want to delete all installation files to free up space, execute:

   dpkg -l | grep tensorrt

Check the installation package name. If it is nv-tensorrt-repo-ubuntu1804-cuda11.1-trt7.2.1.6-ga-20201007, execute:

sudo dpkg -P nv-tensorrt-repo-ubuntu1804-cuda11.1-trt7.2.1.6-ga-20201007

In this way, directory files such as /var/nv-tensorrt-repo-ubuntu1804-cuda11.1-trt7.2.1.6-ga-20201007_1-1 are deleted.

Install TensorRT on the Ubuntu host according to https://docs.nvidia.com/deeplearning/tensorrt/install-guide/index.html#installing-debian. Download the deb file of the installation repo and execute the following steps. If you install TensorRT7.2.1 version adapted to CUDA10.2, execute:

sudo dpkg -i nv-tensorrt-repo-ubuntu1804-cuda10.2-trt7.2.1.6-ga-20201006_1-1_amd64.deb

   sudo apt-key add /var/nv-tensorrt-repo-cuda10.2-trt7.2.1.6-ga-20201006/7fa2af80.pub

   sudo apt-get update

   sudo apt-get install tensorrt

If you are installing in a Docker container , you cannot use the above steps, otherwise you will always encounter errors like the following in the last step of the installation:

The following packages have unmet dependencies:
tensorrt : Depends: libnvinfer-dev (= 7.2.1-6+cuda10.2) but 8.0.0-1+cuda11.3 is to be installed
Depends: libnvinfer-plugin-dev (= 7.2.1-6+cuda10.2) but 8.0.0-1+cuda11.3 is to be installed
Depends: libnvparsers-dev (= 7.2.1-6+cuda10.2) but 8.0.0-1+cuda11.3 is to be installed
Depends: libnvonnxparsers-dev (= 7.2.1-6+cuda10.2) but 8.0.0-1+cuda11.3 is to be installed
Depends: libnvinfer-samples (= 7.2.1-6+cuda10.2) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

CUDA10.2 is clearly installed in the container, and TensorRT is also version 7.2.1.6+cuda10.2, but it always reports similar errors. It is still the same when changing to other versions. It is very frustrating. Later, I carefully read NVIDIA's documents and found

It seems that another way is needed to install TensorRT in the docker container. However, it is troublesome to install a bunch of libnvinfer* libraries (change 8 to 7 as needed) using the Network Repo method:

And after installing it, I found that there were still various problems when compiling the program later, even the method of specifying the version had the same problem:

After a while of trying again, I still got it wrong. Finally, I looked down and found this simplest and most reliable way:

In other words, the inexplicable error reported at the beginning is actually because the NVIDIA CUDA network repository is configured in the docker container. After manually downloading and installing the TensorRT local repository such as nv-tensorrt-repo-ubuntu1804-cuda10.2-trt7.2.1.6-ga-20201006_1-1_amd64.deb, if you use sudo apt-get install tensorrt to install it, there will be a package conflict due to the two sources. You only need to add a file local-repo under /etc/apt/preferences.d/ with the content:

Package: *
Pin: origin ""
Pin-Priority: 1001

Then execute

 sudo apt-get update
 sudo apt-get install tensorrt

The version cuda10.2-trt7.2.1.6 corresponding to the local repo was successfully installed, and there were no errors in compiling the program!

I feel that NVIDIA's documentation is really poorly written in some places. Can't they explain clearly and completely the installation for each environment separately? They have to mix a lot of things together and let users go through the pits one by one.

In addition, if you are using an RTX30 series GPU, the CUDA version needs to be >= 11.1. Otherwise, although TensorRT can be installed, the following error may be reported during actual runtime:

[W] [TRT] Half2 support requested on hardware without native FP16 support, performance will be negatively affected.
[E] [TRT] ../rtSafe/cuda/caskUtils.cpp (98) - Assertion Error in trtSmToCask: 0 (Unsupported SM.)

Although 11.1.0 can be used, the following errors may occur when compiling certain programs such as caffe or darknet:

nvcc fatal: Unsupported gpu architecture 'compute_86'

Therefore, for RTX30 series GPUs, it is best to install CUDA version >= 11.1.1

The above is the details of the problem of installing TensorRT in the docker container. For more information about installing TensorRT in docker, please pay attention to other related articles on 123WORDPRESS.COM!

You may also be interested in:
  • Pytorch converts to TensorRT5 by saving as ONNX model
  • How to install docker on Linux system and log in to docker container through ssh
  • How to install and uninstall docker application container engine under Centos7
  • Summary of common Docker commands: installation, mirroring, and basic container operations
  • Specific steps to install ssh in the docker container

<<:  Refs and Ref Details in Vue3

>>:  MySQL table field time setting default value

Recommend

How to use Vue+ElementUI Tree

The use of Vue+ElementUI Tree is for your referen...

CentOS 8 is now available

CentOS 8 is now available! CentOS 8 and RedHat En...

Analyze MySQL replication and tuning principles and methods

1. Introduction MySQL comes with a replication so...

Node.js+express message board function implementation example

Table of contents Message Board Required librarie...

Detailed explanation of mysql partition function and example analysis

First, what is database partitioning? I wrote an ...

Example code for using @media in CSS3 to achieve web page adaptation

Nowadays, the screen resolution of computer monit...

MySQL 5.7.20 compressed version download and installation simple tutorial

1. Download address: http://dev.mysql.com/downloa...

Example of removing json backslash in php

1. Remove backslashes through the "stripslas...

A detailed explanation of the subtle differences between Readonly and Disabled

Readonly and Disabled both prevent users from chan...

Basic operations of mysql learning notes table

Create Table create table table name create table...

Using cursor loop to read temporary table in Mysql stored procedure

cursor A cursor is a method used to view or proce...

mysql subquery and join table details

Table of contents 1. What is a subquery? 2. Self-...