tensorrt6不支持pytorch1.9
使用tensorrt加载一个pytorch1.9训练完导出为onnx的模型报以下错误:
Input filename: ../data/model.onnx
ONNX IR version: 0.0.6
Opset version: 10
Producer name: pytorch
Producer version: 1.9
Domain:
Model version: 0
Doc string:
----------------------------------------------------------------
WARNING: ONNX model has a newer ir_version (0.0.6) than this parser was built against (0.0.3).
While parsing node number 0 [Conv]:
ERROR: ModelImporter.cpp:296 In function importModel:
[5] Assertion failed: tensors.count(input_name)
[07/02/2021-11:46:52] [E] Failed to parse onnx file
[07/02/2021-11:46:52] [E] Parsing model failed
[07/02/2021-11:46:52] [E] Engine could not be created
&&&& FAILED TensorRT.trtexec # trtexec.exe --onnx=../data/model.onnx
网上查了查,就是版本问题。
github有相关探讨:
https://github.com/onnx/onnx-tensorrt/issues/199#issuecomment-524145151
你可以先用python把你的模型加载一下:
import onnx
model = onnx.load_model('model.onnx')
print(model)
没报错就没问题。
或者检查一下:
import onnx
print(onnx.checker.check_model('model.onnx'))
没报错就没问题。
我都没报错,只能是版本问题,底下的参考中修改了源码,但是可能会导致更多的问题,我就没有尝试了。