tensorRT6.0.1.5安装

TensorRT-6.0.1.5.Ubuntu-16.04.x86_64-gnu.cuda-10.1.cudnn7.6.tar.gz安装

TensorRT的tar文件安装教程:https://docs.nvidia.com/deeplearning/tensorrt/install-guide/index.html#installing-tar

本文环境

ubuntu16.04
cuda-10.1

创建虚拟环境

conda create -n trt python =3.7

解压tar文件
tar xzvf TensorRT-6.0.1.5.Ubuntu-16.04.x86_64-gnu.cuda-10.1.cudnn7.6.tar.gz 
将绝对路径添加到TensorRTLIB 目录到环境变量LD_LIBRARY_PATH

打开.bashrc
vim ~/.bashrc
在最下面加入解压的TensorRT的Lib路径

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/guest/Downloads/TensorRT-6.0.1.5/lib

最后source激活
source ~/.bashrc

安装Python TensorRT wheel文件
cd TensorRT-${version}/python

#如果使用Python 2.7:

sudo pip2 install tensorrt-*-cp27-none-linux_x86_64.whl

#如果使用Python 3.x:

sudo pip3 install tensorrt-*-cp3x-none-linux_x86_64.whl
安装Python UFF wheel文件。仅当您计划将TensorRT与TensorFlow一起使用时才需要这样做
cd TensorRT-${version}/uff
如果使用Python 2.7:
sudo pip2 install uff-0.6.9-py2.py3-none-any.whl
如果使用Python 3.x:
sudo pip3 install uff-0.6.9-py2.py3-none-any.whl
不论哪种情况,请使用以下方法检查安装:
which convert-to-uff
安装Python graphsurgeon wheel文件
cd TensorRT-${version}/graphsurgeon
If using Python 2.7:
sudo pip2 install graphsurgeon-0.4.5-py2.py3-none-any.whl
If using Python 3.x:
sudo pip3 install graphsurgeon-0.4.5-py2.py3-none-any.whl
安装Python onnx-graphsurgeon wheel文件。

安装包内无onnx-graphsurgeon文件夹

cd TensorRT-${version}/onnx_graphsurgeon
If using Python 2.7:
sudo pip2 install onnx_graphsurgeon-0.2.6-py2.py3-none-any.whl
If using Python 3.x:
sudo pip3 install onnx_graphsurgeon-0.2.6-py2.py3-none-any.whl
验证安装
a、确保已安装的文件位于正确的目录中。例如,运行tree-d 命令检查所有受支持的安装文件是否在 lib, include, data等目录。
b、生成并运行其中一个样品,例如, 样本MNIST在安装目录中。您应该能够在没有其他设置的情况下编译和执行示例。有关更多信息,请参见“Hello World” For TensorRT (sampleMNIST)https://github.com/NVIDIA/TensorRT/tree/master/samples/opensource/sampleMNIST
c、Python示例位于 样本/ python 目录。
运行sample

通过make<TensorRT root directory>/samples/sampleMNIST目录中运行来编译此示例。名为的二进制文件sample_mnist将在<TensorRT root directory>/bin目录中创建。

cd <TensorRT root directory>/samples/sampleMNIST
make

本示例读取三个Caffe文件以构建网络:

  • mnist.prototxt 包含网络设计的prototxt文件。
  • mnist.caffemodel 包含网络训练的权重的模型文件。
  • mnist_mean.binaryproto 包含均值的binaryproto文件。

查看data/mnist文件夹中是否有上述三个文件

下载mnist数据集,只需下载以下两个即可

训练图片:http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz

训练图片标签:http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz

下载好后解压

gzip -d filename.gz
生成手写体数字pgm文件
cd <TensorRT root directory>/data/mnist
python generate_pgms.py

次步会生成0到9的手写体数字pgm文件

测试结果

cd <TensorRT root directory>/bin
./sample_mnist [-h] [--datadir=/path/to/data/dir/] [--useDLA=N] [--fp16 or --int8]
#其实只需要./sample_mnist 就可以运行了,后面的都可以不加就可以看到结果
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值