onnx 转 trt 的时候出现错误:
[04/22/2022-15:45:13] [W] [TRT] onnx2trt_utils.cpp:220: Your ONNX model has been generated with INT64 weights, while TensorRT does not natively support INT64. Attempting to cast down to INT32.
[04/22/2022-15:45:13] [E] [TRT] (Unnamed Layer* 371) [Shuffle]: at most one dimension may be inferred
ERROR: onnx2trt_utils.cpp:1517 In function scaleHelper:
[8] Assertion failed: dims.nbDims == 4 || dims.nbDims == 5
[04/22/2022-15:45:13] [E] Failed to parse onnx file
[04/22/2022-15:45:13] [E] Parsing model failed
[04/22/2022-15:45:13] [E] Engine creation failed
[04/22/2022-15:45:13] [E] Engine set up failed
按照?这篇文章,可以解决,但是需要升级 trt。
不升级 trt的解决方式是,重新编译 libnvonnxparser.so,替换 trtexec 使用的版本。
具体步骤是:(假设当前trt版本是7.2.1.6,被安装在/usr/local/TensroRT7.2.1.6)
1、下载
git clone -b 7.2.1 https://github.com/onnx/onnx-tensorrt.git
2、编译
cd onnx-tensorrt
git submodule update --init --recursive
mkdir build && cd build
cmake .. -DTENSORRT_ROOT=/usr/local/TensorRT-7.2.1.6 && make -j
3、用 ldd trtexec 看下它依赖的 libnvonnxparser.so 在哪,用新生成的相应文件替换即可。
参考:
Problem converting ONNX model to TensorRT 7.2.1 (worked in previous 7.1.3 release) · Issue #566 · onnx/onnx-tensorrt · GitHub
|