jetson nano onnx-tensorrt 7.1

2 篇文章 0 订阅
2 篇文章 0 订阅

 onnx -> tensorRT 当下是比较火的 深度学习模型 加速, 验证项目里用到,这里记录一下:

一 升级 protobuf 为 protobuf 3.8 

git clone https://github.com/google/protobuf -b '3.8.x'

apt remove libprotobuf-dev # uninstall old version 

cd protobuf && ./autogen.sh && ./configure --prefix=/usr/ && make -j6 && make install -j6

注: 升级完 python的 protobuf 模块也要更新: (否则 依赖protobuf 的很多py 模型跑不跑 悲剧 了。)

pip3 uninstall protobuf

pip install protobuf==3.8.0 

#2 onnx-tensorrt 

git clone --recursive -b 7.1  https://github.com/onnx/onnx-tensorrt.git

二 下载 onnx-tensorrt 代码:

# 科鞋上网, 注意 选择与 jetpack 4.4.1 兼容的 7.1 版本

git clone --recursive -b 7.1  https://github.com/onnx/onnx-tensorrt.git  onnx_tensorrt_7.1

三 编译安装 :

# build.sh 

export PATH=/opt/cmake_3_18_4/bin/:/usr/local/cuda/bin:$PATH
cmake  -DCUDA_INCLUDE_DIRS=/usr/local/cuda/include -DTENSORRT_ROOT=/usr/src/tensorrt -DCMAKE_INSTALL_PREFIX=/usr/ \
    ..
make -j8

make install

# 安装 python模块
cd  onnx-tensorrt 

## 安装 python模块依赖
apt install swig 

## 安装 python模块
python3 setup.py install 

遇到错误如下, 以及解决办法:

https://github.com/onnx/onnx-tensorrt/issues/350

Applied patch

--- a/NvOnnxParser.h
+++ b/NvOnnxParser.h
@@ -31,6 +31,10 @@
 #define NV_ONNX_PARSER_MINOR 1
 #define NV_ONNX_PARSER_PATCH 0

+#ifndef TENSORRTAPI
+#define TENSORRTAPI
+#endif // TENSORRTAPI
+
 static const int NV_ONNX_PARSER_VERSION = ((NV_ONNX_PARSER_MAJOR * 10000) + (NV_ONNX_PARSER_MINOR * 100) + NV_ONNX_PARSER_PATCH);

 //! \typedef SubGraph_t
diff --git a/setup.py b/setup.py
index 8ffa543..d6244a3 100644
--- a/setup.py
+++ b/setup.py
@@ -59,10 +59,11 @@ EXTRA_COMPILE_ARGS =  [
     '-std=c++11',
     '-DUNIX',
     '-D__UNIX',
-    '-m64',
     '-fPIC',
     '-O2',
     '-w',
+    '-march=armv8-a+crypto',
+    '-mcpu=cortex-a57+crypto',
     '-fmessage-length=0',
     '-fno-strict-aliasing',
     '-D_FORTIFY_SOURCE=2',
  • 4
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

walletiger

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值