Ubuntu:E: 无法定位软件包 tensorrt(包括如何安装tensorrt)

在按照网上的教程安装tensorrt中遇到的问题

首先是tensorrt的安装步骤:

1.在Installation Guide :: NVIDIA Deep Learning TensorRT Documentation下载对应版本的tensorrt

2.解压安装

sudo dpkg -i nv-tensorrt-repo-ubuntu1604-cuda9.0-trt5.1.5.0-ga-20190427_1-1_amd64.deb
sudo apt-key -add /var/nv-tensorrt-repo-cuda9.0-trt5.1.5.0-ga-20190427/7fa2af80.pub

3.sudo apt-get update

4.sudo apt-get install tensorrt

在执行第4步的过程之中遇见了如下问题:

E: 无法定位软件包 tensorrt 

(base) liyi@liyi:~$ sudo apt-get install tensorrt
正在读取软件包列表... 完成
正在分析软件包的依赖关系树       
正在读取状态信息... 完成       
E: 无法定位软件包 tensorrt

在折腾之后发现还是无法解决。

(目前怀疑是因为下载的Tensorrt的版本过低,没有相对应的python版本。因为在后续下载压缩包的过程之中我下载过相同的版为就是因为没有对应的python版本所以转用更高版本的Tensorrt;但是这只是我的猜测,没有测试过高版本能否安装成功)


因此更换安装方法,下载对应版本的压缩包

我下载的是TensorRT-8.0.0.3.Linux.x86_64-gnu.cuda-10.2.cudnn8.2.tar.gz

接下来1.解压压缩包

tar -xzvf TensorRT-8.0.0.3.Linux.x86_64-gnu.cuda-10.2.cudnn8.2.tar.gz

2. 

cd cd /TensorRT-8.0.0.3/python

3.选择对应的版本进行安装

sudo pip3 install tensorrt-8.0.0.3-cp38-none-linux_x86_64.whl

安装成功

Processing ./tensorrt-8.0.0.3-cp38-none-linux_x86_64.whl
Installing collected packages: tensorrt
Successfully installed tensorrt-8.0.0.3

 接下来的也需要进行安装 

#安装UFF
cd TensorRT-XXXXXX/uff
pip install uff-0.6.5-py2.py3-none-any.whl
 
#安装graphsurgeon
cd TensorRT-XXXXXX/graphsurgeon
pip install graphsurgeon-0.4.1-py2.py3-none-any.whl

在安装成功之后依然不能使用

原因我的cuda版本为10.2,python版本为3.8

但是对应python3.8的只有cuda11的,因此需要更换其中的一个版本。

(base) liyi@liyi:~/TensorRT-8.0.0.3/python$ python 
Python 3.8.5 (default, Sep  4 2020, 07:30:14) 
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorrt
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/liyi/miniconda3/lib/python3.8/site-packages/tensorrt/__init__.py", line 67, in <module>
    from .tensorrt import *
ImportError: libnvrtc.so.10.2: cannot open shared object file: No such file or directory


版权声明:本文为LYiiiiiii原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。