安装tensorrt

写在前面:折腾了一下午的Tensorrt,终于装好了,仅仅以此记录一下我的安装过程。

1、我是手动安装,需要自己去官网下载对应的tar安装包,解压

tar xvf TensorRT-6.0.1.8.Ubuntu-18.04.x86_64-gnu.cuda-10.2.cudnn7.6.tar.gz

2、激活自己的虚拟环境

source activate faster-rcnn

3、安装

cd python
# 安装别的版本,我会报错说版本不对
pip install tensorrt-6.0.1.8-cp36-none-linux_x86_64.whl

4、拷贝

sudo mkdir -p /usr/lib/tensorrt
cd ..
sudo cp -a lib/* /usr/lib/tensorrt
source ~/.bashrc

5、安装torch2trt
torch2trt代码地址

cd torch2trt
python setup.py install

python
import tensorrt

不报错即可

6、随后自己照着README文档测试了一下,确实没问题。
会有如下警告UserWarning: Named tensors and all their associated APIs are an experimental feature and subject to change. Please do not use them for anything important until they are released as stable.因为pytorch版本不对,忽略即可。

7、之后加速YOLOP的,不过会出现如下错误:
Warning: Encountered known unsupported method torch.nn.functional.has_torch_function_unary
Warning: Encountered known unsupported method torch.nn.functional.hardtanh
Warning: Encountered known unsupported method torch.Tensor.to
应该是tensorrt不支持这几个函数,需要自己写一下转换文件,目前还没解决这个问题,希望有懂哥知道的话能指导指导~

你可能感兴趣的:(ubuntu)