TensorRT安裝和Hello World

安裝

1. 官網下載tensorRT的安裝包,解壓即可,使用時在CMakeLists裏指定頭文件和庫文件位置即可。不推薦使用deb文件安裝,因爲它要求配置文件也是deb文件安裝。

2. 下載對應的cuda版本和cudnn版本,cuda版本一定要嚴格對應。
我的配置是ubuntu16.04,cuda9.0,cudnn7.3
cudnn版本我沒使用官網指定的7.6,雖然會警告,程序還是可以運行。

Hello World

運行sample裏的mnist程序。
在sample/sampleMNIST下編譯後在根目錄bin文件夾下執行即可

cd /TensorRT-6.0.1.5/samples/sampleMNIST/
make
cd ../../bin/
./sample

運行結果:

$ ./sample_mnist 
&&&& RUNNING TensorRT.sample_mnist # ./sample_mnist
[09/29/2019-15:46:14] [I] Building and running a GPU inference engine for MNIST
[09/29/2019-15:46:14] [W] [TRT] TensorRT was linked against cuDNN 7.6.3 but loaded cuDNN 7.3.0
[09/29/2019-15:46:15] [I] [TRT] Detected 1 inputs and 1 output network tensors.
[09/29/2019-15:46:15] [W] [TRT] TensorRT was linked against cuDNN 7.6.3 but loaded cuDNN 7.3.0
[09/29/2019-15:46:15] [W] [TRT] TensorRT was linked against cuDNN 7.6.3 but loaded cuDNN 7.3.0
[09/29/2019-15:46:15] [I] Input:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@.*@@@@@@@@@@
@@@@@@@@@@@@@@@@.=@@@@@@@@@@
@@@@@@@@@@@@+@@@.=@@@@@@@@@@
@@@@@@@@@@@% #@@.=@@@@@@@@@@
@@@@@@@@@@@% #@@.=@@@@@@@@@@
@@@@@@@@@@@+ *@@:-@@@@@@@@@@
@@@@@@@@@@@= *@@= @@@@@@@@@@
@@@@@@@@@@@. #@@= @@@@@@@@@@
@@@@@@@@@@=  =++.-@@@@@@@@@@
@@@@@@@@@@       =@@@@@@@@@@
@@@@@@@@@@  :*## =@@@@@@@@@@
@@@@@@@@@@:*@@@% =@@@@@@@@@@
@@@@@@@@@@@@@@@% =@@@@@@@@@@
@@@@@@@@@@@@@@@# =@@@@@@@@@@
@@@@@@@@@@@@@@@# =@@@@@@@@@@
@@@@@@@@@@@@@@@* *@@@@@@@@@@
@@@@@@@@@@@@@@@= #@@@@@@@@@@
@@@@@@@@@@@@@@@= #@@@@@@@@@@
@@@@@@@@@@@@@@@=.@@@@@@@@@@@
@@@@@@@@@@@@@@@++@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@

[09/29/2019-15:46:15] [I] Output:
0: 
1: 
2: 
3: 
4: **********
5: 
6: 
7: 
8: 
9: 

&&&& PASSED TensorRT.sample_mnist # ./sample_mnist

報錯:

libnvinfer.so.5: cannot open shared object file: No such file or directory
將對應的庫文件從tensorRT/lib/下拷貝到/usr/lib下,再重新編譯sampleMNIST

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章