安装onnx-tensorrt的艰辛之路

  • 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

此番操作出现的问题可能有

  1. 下载下来的安装包里/third_party/onnx 下是空的,因此下载onnx源码包,(与pip install onnx不同哦)注意这里一定要选对版本!!onnx1.6 针对的是TensorRT7,我是TensorRT5,于是选了onnx1.4,刚好可以cmake成功;
    CMake成功截图

  2. 在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安装成功的截图
在这里插入图片描述

  • 7
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 9
    评论
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值