本文主要简要介绍TensorRT的环境搭建及如何使用。
环境安装
我这里使用的是TensorRT-5.1.5.0版本,其他版本可能会有一些出入。
安装好的TensorRT环境的docker镜像(docker pull 857470845/hvd_trt_apex_torch:v1)可供下载使用。
示例运行
主要测试两种示例:1、利用安装好的convert_to_uff.py脚本将tensorflow的pb模型文件(lenet)转成uff格式文件,并测试mnist数据;
将TensorRT-5.1.5.0项目所在路径挂载到/mnt下
##cd /mnt/TensorRT-5.1.5.0/samples/python/end_to_end_tensorflow_mnist
mkdir models
python model.py
##convert_to_uff.py脚本在镜像中的路径:/opt/conda/lib/python3.6/site-packages/uff/bin/convert_to_uff.py
python /opt/conda/lib/python3.6/site-packages/uff/bin/convert_to_uff.py --input_file models/lenet5.pb
2、直接测试samples/sampleMNIST程序
可以直接在samples下make,产生所有的示例的bin;不过我这里是只单独编译测试samples/sampleMNIST示例。
root@gpuserver002:/mnt/TensorRT-5.1.5.0/bin# ./sample_mnist --int8
&&&& RUNNING TensorRT.sample_mnist # ./sample_mnist --int8
[I] Building and running a GPU inference engine for MNIST
[W] [TRT] Calibrator is not being used. Users must provide dynamic range for all tensors that are not Int32.
[W] [TRT] Warning: no implementation of (Unnamed Layer* 9) [Constant] obeys the requested constraints, using a higher precision type
[W] [TRT] Warning: no implementation of ip2 obeys the requested constraints, using a higher precision type
[W] [TRT] Warning: no implementation of prob obeys the requested constraints, using a higher precision type
[I] Input:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@%+-: =@@@@@@@@@@@@
@@@@@@@%= -@@@**@@@@@@@
@@@@@@@ :%#@-#@@@. #@@@@@@
@@@@@@* +@@@@:*@@@ *@@@@@@
@@@@@@# +@@@@ @@@% @@@@@@@
@@@@@@@. :%@@.@@@. *@@@@@@@
@@@@@@@@- =@@@@. -@@@@@@@@
@@@@@@@@@%: +@- :@@@@@@@@@
@@@@@@@@@@@%. : -@@@@@@@@@@
@@@@@@@@@@@@@+ #@@@@@@@@@@
@@@@@@@@@@@@@@+ :@@@@@@@@@@
@@@@@@@@@@@@@@+ *@@@@@@@@@
@@@@@@@@@@@@@@: = @@@@@@@@@
@@@@@@@@@@@@@@ :@ @@@@@@@@@
@@@@@@@@@@@@@@ -@ @@@@@@@@@
@@@@@@@@@@@@@# +@ @@@@@@@@@
@@@@@@@@@@@@@* ++ @@@@@@@@@
@@@@@@@@@@@@@* *@@@@@@@@@
@@@@@@@@@@@@@# =@@@@@@@@@@
@@@@@@@@@@@@@@. +@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@
[I] Output:
0:
1:
2:
3:
4:
5:
6:
7:
8: **********
9:
&&&& PASSED TensorRT.sample_mnist # ./sample_mnist --int8
推荐工程:
https://github.com/NVIDIA/object-detection-tensorrt-example
https://github.com/NVIDIA/healthcare-on-tap-TRT-TRITON-demo
References
下载链接: https://developer.nvidia.com/nvidia-tensorrt-download
trt工程: https://docs.nvidia.com/deeplearning/tensorrt/developer-guide/index.html
项目地址: https://github.com/NVIDIA/TensorRT
参考博客: https://blog.youkuaiyun.com/zong596568821xp/article/details/86077553
Triton(tensorrt inference server): https://github.com/triton-inference-server/server