本文介绍 嵌入式深度学习二:TensorRT Runtime安装
嵌入式深度学习二:TensorRT Runtime安装
This article was original written by Jin Tian, welcome re-post, first come with https://jinfagang.github.io . but please keep this copyright info, thanks, any question could be asked via wechat: jintianiloveu
TensorRT Python Library 要把TensorFlow的模型用TensorRT加速,首先安装TensorRT库,实际上官方的deb的包并没有什么太大的用处,直接从tar包下载下来安装:
1
https://developer.nvidia.com/nvidia-tensorrt-download
选择cuda8.0
和cudnn7
的tar包来安装。先安装一下python接口吧,直接:
1
2
3
cd TensorRT-3.0.1
cd python
sudo pip3 install tensorrt-3.0.1-cp35-cp35m-linux_x86_64.whl
但是这里你可能会遇到一个错误:
1
2
3
4
In file included from src/cpp/cuda.cpp:1:0:
src/cpp/cuda.hpp:14:18: fatal error: cuda.h: No such file or directory
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
找不到cuda.hpp,解决方法:
1
2
3
4
sudo touch /etc/profile.d/cuda.sh
export PATH=/usr/local/cuda/bin/:$PATH >> /etc/profile.d/cuda.sh
sudo su -
pip3 install tensorrt-3.0.1-cp35-cp35m-linux_x86_64.whl
原因是不能用sudo,这样应该是可以成功安装TensorRT的python库。(new a terminal)
最后后得安装一下uff:
1
2
cd uff
sudo pip3 install uff-0.2.0-py2.py3-none-any.whl
测试一下tensorrt的python库是否安装成功:
1
2
3
4
5
Python 2.7.12 (default, Nov 20 2017, 18:23:56)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorrt
>>>
TensorRT C++ Runtime TensorRT实际上只是一个动态链接库,并没有具体的实现,如果你要实现自己TensorRT库,你需要实现自己的层。如果要让自己的C++程序正确找到依赖,直接把TensorRT的解压路径添加到library path里面。