在Ubuntu 18.04上安装TensorRT时遇到了libnvinfer7库(Cuda 10.2)的问题。

10

我尝试在Ubuntu 18.4上安装TensorRT 7.0(nv-tensorrt-repo-ubuntu1804-cuda10.2-trt7.0.0.11-ga-20191216_1-1_amd64.deb) Debian。

按照文档https://docs.nvidia.com/deeplearning/tensorrt/install-guide/index.html#installing-debian进行操作。

使用libnvinfer7时出现以下错误。在全球范围内搜索无法找到解决方法,浪费了我的时间和睡眠。请帮我解决这个问题:

 amarnath@amarnath-Precision-T3610:/opt/pixuate$ sudo apt install tensorrt
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    Some packages could not be installed. This may mean that you have
    requested an impossible situation or if you are using the unstable
    distribution that some required packages have not yet been created
    or been moved out of Incoming.
    The following information may help to resolve the situation:

    The following packages have unmet dependencies:
     tensorrt : Depends: libnvinfer7 (= 7.0.0-1+cuda10.2) but it is not going to be installed
                Depends: libnvinfer-plugin7 (= 7.0.0-1+cuda10.2) but it is not going to be installed
                Depends: libnvparsers7 (= 7.0.0-1+cuda10.2) but it is not going to be installed
                Depends: libnvonnxparsers7 (= 7.0.0-1+cuda10.2) but it is not going to be installed
                Depends: libnvinfer-bin (= 7.0.0-1+cuda10.2) but it is not going to be installed
                Depends: libnvinfer-dev (= 7.0.0-1+cuda10.2) but it is not going to be installed
                Depends: libnvinfer-plugin-dev (= 7.0.0-1+cuda10.2) but it is not going to be installed
                Depends: libnvparsers-dev (= 7.0.0-1+cuda10.2) but it is not going to be installed
                Depends: libnvonnxparsers-dev (= 7.0.0-1+cuda10.2) but it is not going to be installed
                Depends: libnvinfer-samples (= 7.0.0-1+cuda10.2) but it is not going to be installed
                Depends: libnvinfer-doc (= 7.0.0-1+cuda10.2) but it is not going to be installed
    E: Unable to correct problems, you have held broken packages.

好的,尝试了 "sudo apt-get install python3-libnvinfer-dev"

amarnath@amarnath-Precision-T3610:/opt/pixuate$ sudo apt-get install python3-libnvinfer-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

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

你有读过这个吗:https://docs.nvidia.com/deeplearning/tensorrt/install-guide/index.html#installing-debian? - talonmies
@talonmies,是的,我按照文档中的确切步骤进行了操作。 - Amarnath R
1
你在问题中没有提到这一点。此外,这是一个“早期访问”版本,所以可能无法正常工作。请联系NVIDIA。我已经投票关闭了它,因为它不适合在这里讨论。 - talonmies
@talonmies 我正在编辑它。 - Amarnath R
https://askubuntu.com/questions/363200/e-unable-to-correct-problems-you-have-held-broken-packages - talonmies
3个回答

7
在来自https://docs.nvidia.com/deeplearning/tensorrt/install-guide/index.html的TensorRT安装部分中,有这样一句话:
需要使用Debian或RPM包安装CUDA Toolkit和cuDNN。
如果你使用deb文件安装CUDA toolkit和cuDNN,则应该解决未满足依赖关系错误注意:在安装之前,请检查要安装的Ubuntu、CUDA和cuDNN版本。在安装提示中,使用的是CUDA 10.2和cuDNN 7.6.5。这经过了对TensorRT 7.0.0的测试。

CUDA .deb安装

wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804x86_64cuda-ubuntu1804.pin  
sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget http://developer.download.nvidia.com/compute/cuda/10.2/Prod/local_installers/cuda-repo-ubuntu1804-10-2-local-10.2.89-440.33.01_1.0-1_amd64.deb
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

CUDNN .deb 安装

首先下载 .deb 文件:

  1. Ubuntu18.04 的 cuDNN 开发者库 (Deb)
  2. Ubuntu18.04 的 cuDNN 运行时库 (Deb)

然后安装已下载的软件包:

sudo dpkg -i libcudnn7_7.6.5.32-1+cuda10.2_amd64.deb
sudo dpkg -i libcudnn7-dev_7.6.5.32-1+cuda10.2_amd64.deb

注意:这些安装说明来自官方的Nvidia网站。


2

默认情况下,系统会尝试将libnvinfer版本升级到最新版本(包括升级CUDA到11.x版本)。

因此,我们首先需要安装必要的版本,然后对它们进行保持以限制任何可能导致未满足依赖关系的自动升级尝试。

sudo apt-get install libnvinfer7=7.0.0-1+cuda10.2 libnvonnxparsers7=7.0.0-1+cuda10.2 libnvparsers7=7.0.0-1+cuda10.2 libnvinfer-plugin7=7.0.0-1+cuda10.2 libnvinfer-dev=7.0.0-1+cuda10.2 libnvonnxparsers-dev=7.0.0-1+cuda10.2 libnvparsers-dev=7.0.0-1+cuda10.2 libnvinfer-plugin-dev=7.0.0-1+cuda10.2  python3-libnvinfer=7.0.0-1+cuda10.2

sudo apt-mark hold libnvinfer7 libnvonnxparsers7 libnvparsers7 libnvinfer-plugin7 libnvinfer-dev libnvonnxparsers-dev libnvparsers-dev libnvinfer-plugin-dev python3-libnvinfer python3-libnvinfer-dev

安装完毕后,您可以轻松安装TensorRT:
sudo apt-get install tensorrt

谢谢。它可以工作了。我曾经费了很大的劲尝试安装旧库! - Vu Tran

0
我在使用tensorrt 8.2.5-1和cuda11.6时遇到了这个问题:
tensorrt依赖于libnvinfer-samples (= 8.2.5-1+cuda11.4),但它无法安装。
通过安装cuda 11.7和tensorrt 8.4.1.5来解决了这个问题。 TensorRT安装失败,缺少libnvinfer-samples

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接