TensorRT5 yoloV3加速

TensorRT5中的yoloV3加速

原文:https://blog.csdn.net/qq_22764813/article/details/85626501

有项目地址:https://github.com/lewes6369/TensorRT-Yolov3

之前做过caffe版本的yolov3加速,然后实际运用到项目上后,发现原始模型在TX2(使用TensorRT加速后,FP16)上运行260ms,进行L1 排序剪枝后原始模型由246.3M压缩到64.8M,但是时间运行只提速到了142ms(目标是提速到100ms以内),很是捉急。

与libtorch差不多。

最近发现TensorRT5的sampleszhong有yolov3 onnx版本的TensorRT加速(虽然是python版本的),所以准备阅读TensorRT的原始demo作为再加速的依据,看完后发现和C++版本没有什么区别;

 

遇到的bug:

1)[libprotobuf ERROR google/protobuf/io/zero_copy_stream_impl_lite.cc:173] Cannot allocate buffer larger than kint32max for StringOutputStream.

这个问题是protobuf的自身的bug,解决这个问题只需要将使用的protobuf升级就可以了,可以在pycharm中查看使用的protobuf版本:

TensorRT5 yoloV3加速_第1张图片

查看红框标注的protobuf的版本,双击“3.6.1”的位置,就可以指定相应的版本安装,报错之前protobuf的版本是3.0版本,已经升级为当前最新的版本3.6.1.然后成功解决错误;

参考:https://github.com/tensorflow/tensorflow/issues/9337,其中重要的话摘录如下:

 
  1. Basically, graph is too big. This is not a bug in tensorflow itself, I would

  2. suggest you ask on stackoverflow for ways to reduce the graph size.

不过话说回来,这个问题产生于protobuf,但回答的人都与tensorflow相关(不过由此联想是protobuf版本要升级);

2)初次使用python API在tensorRT上加速,遇到bug:ImportError: No module named tensorrt

解决方法:

 sudo pip install TensorRT-4.0.1.6/python/tensorrt-4.0.1.6-cp27-cp27mu-linux_x86_64.whl

参考:https://github.com/NVIDIA-AI-IOT/tf_to_trt_image_classification

3)遇到bug:ImportError: libnvinfer.so.5: cannot open shared object file: No such file or directory

sudo cp TensorRT-5.XXX/targets/x86_64-linux-gnu/lib/lib* /usr/lib/

你可能感兴趣的:(torch)