onnx-tensorrt踩坑记录

本文详细介绍了如何从GitHub克隆并安装ONNX-TensorRT,包括设置环境变量、安装protobuf以及解决常见问题的过程。
部署运行你感兴趣的模型镜像

github地址:https://github.com/onnx/onnx-tensorrt/tree/master

安装onnx-tensorrt

最新版似乎没有安装的教程,但是可以根据旧版来安装。
先把旧版完整的安装过程列出来:

git clone --recursive https://github.com/onnx/onnx-tensorrt.git
mkdir build
cd build
cmake .. -DTENSORRT_ROOT=<tensorrt_install_dir>
OR
cmake .. -DTENSORRT_ROOT=<tensorrt_install_dir> -DGPU_ARCHS="61"
make -j8
sudo make install

首先,clone代码可以使用:

git clone --recurse-submodules https://github.com/onnx/onnx-tensorrt.git

在安装前,要确保protobuf的版本满足条件,不然后续安装会花费大量时间(多么痛的领悟)。

安装protobuf

因为我安装了anaconda,自带protoc,网上没找到合适的教程,就把它直接卸载了:

which protoc
rm /path/to/protoc

然后再查看protoc版本,结果显示3.0.0,应该是ubuntu系统自带的,也顺带卸载。
接着就要去github上下载:https://github.com/protocolbuffers/protobuf/releases
解压:

tar -xvf protobuf-all-3.11.4.tar.gz
  1. 安装:
cd protobuf-3.11.4
./configure
make
make check
make install
  1. 配置环境变量:
gedit ~/.bashrc
添加:
export PATH=$PATH:/usr/local/bin/
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/

保存执行

source ~/.bashrc
  1. 配置动态链接库路径
sudo vi /etc/ld.so.conf

添加:

include /usr/local/protobuf/lib

保存并退出。
共享:

su root
ldconfig

查看protoc版本:

protoc --version

完成。

一些问题

尽量使用下面的cmake方式(加上算力会出一些问题,不知道会不会影响)

cmake .. -DTENSORRT_ROOT=<tensorrt_install_dir>

执行make时出错了,如:fatal error: google/protobuf/port_def.inc: No such file or directory
这应该是protoc出问题了,于是我又看了下cmake的结果,果然发现中间出了错误:

Protobuf compiler version 3.11.4 doesn't match library version 3.0.0
...
-- Found Protobuf: /usr/lib/x86_64-linux-gnu/libprotobuf.so;pthread (found version "3.0.0")

protoc的编译器和库版本不匹配,这就是protoc的动态链接库有问题。

您可能感兴趣的与本文相关的镜像

TensorRT-v8.6

TensorRT-v8.6

TensorRT

TensorRT 是NVIDIA 推出的用于深度学习推理加速的高性能推理引擎。它可以将深度学习模型优化并部署到NVIDIA GPU 上,实现低延迟、高吞吐量的推理过程。

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值