- TensorRT-5.1.5.0
- cudnn 7.5
- cuda 9.0
- python 3.6
- onnx-tensorrt 5.1
- onnx 1.4
- protobuf 3.11.x(对于TensorRT和onnx-tensorrt 5/6/7 都需要protobuf 3.8.x版本及以上)
- googletest
onnx-tensorrt
onnx-tensorrt的安装
https://github.com/onnx/onnx-tensorrt/tree/5.1
因安装的TensorRT为5.x版本,选择onnx-tensorrt下载(一定注意版本!!我因为git clone时没注意版本重复多次哭哭
按照readme走步骤
cd onnx-tensorrt-5.1
mkdir build
cd build
cmake .. -DTENSORRT_ROOT=<tensorrt_install_dir> -DGPU_ARCHS="70" #70为gpu算力,我的是V100
make -j8
make install
此番操作出现的问题可能有
-
下载下来的安装包里/third_party/onnx 下是空的,因此下载onnx源码包,(与pip install onnx不同哦)注意这里一定要选对版本!!onnx1.6 针对的是TensorRT7,我是TensorRT5,于是选了onnx1.4,刚好可以cmake成功;
-
在make -j8 这步,我出现的问题是
/onnx-tensorrt-5.1/build/third_party/onnx/onnx/onnx_onnx2trt_onnx.pb.cc: In member function ‘void onnx2trt_onnx::GraphProto::InternalSwap(onnx2trt_onnx::GraphProto*)’:
/onnx-tensorrt-5.1/build/third_party/onnx/onnx/onnx_onnx2trt_onnx.pb.cc:4084:20: error: ‘CastToBase’ was not declared in this scope
CastToBase(&node_)->InternalSwap(CastToBase(&other->node_));
^
/onnx-tensorrt-5.1/build/third_party/onnx/onnx/onnx_onnx2trt_onnx.pb.cc:4090:24: error: no matching function for call to ‘google::protobuf::internal::ArenaStringPtr::Swap(google::protobuf::internal::ArenaStringPtr*, const string*, google::protobuf::Arena*)’
GetArenaNoVirtual());
.
.
.
想了下应该是protobuf版本问题,又因为在onnx-tensorrt7.x的要求中明确写了
抱着试试看的态度,下载了protobuf 3.11.x
https://github.com/protocolbuffers/protobuf/tree/3.11.x
googletest的安装
首先进入/protobuf-3.11.x/third_party/googletest下,安装googletest
git clone https://github.com/google/googletest
cd googletest
cmake CMakeLists.txt
make
sudo cp libgtest*.a /usr/lib
sudo cp –a include/gtest /usr/include
protobuf的安装
先卸载已有的低版本protobuf
which protoc
rm /path/to.protoc
首先进入/protobuf-3.11.x/third_party下 安装googletest
cd protobuf-3.11.x
./autogen.sh
./configure
make
make check
make instal
查看版本
protoc --version
onnx-tensorrt安装成功的截图