问题1
onnxruntime.capi.onnxruntime_pybind11_state.InvalidGraph: [ONNXRuntimeError] : 10 : INVALID_GRAPH : Load model from reid_1_3_256_128_static.onnx failed:This is an invalid model. Error in Node: : Unrecognized attribute: min for operator Clip
opset_version版本问题,修改为opset_version=9即可
问题2
[07/22/2021-10:47:32] [W] [TRT] onnx2trt_utils.cpp:198: Your ONNX model has been generated with INT64 weights, while TensorRT does not natively support INT64. Attempting to cast down to INT32.
[07/22/2021-11:17:17] [I] [TRT] Detected 1 inputs and 1 output network tensors.
Segmentation fault
或者
[07/21/2021-17:58:15] [W] [TRT] onnx2trt_utils.cpp:198: Your ONNX model has been generated with INT64 weights, while TensorRT does not natively support INT64. Attempting to cast down to INT32.
[07/21/2021-18:28:05] [I] [TRT] Detected 1 inputs and 1 output network tensors.
[07/21/2021-18:28:08] [E] [TRT] FAILED_ALLOCATION: basic_string::_S_construct null not valid
[07/21/2021-18:28:08] [E] Engine serialization failed
[07/21/2021-18:28:08] [E] Saving engine to file failed
Segmentation fault
或者
tensort trt TypeError: a bytes-like object is required, not 'NoneType' python-BaseException
用pycharm会有TRT OutOfMemory Error in computeCosts: 0
表现症状为有trt文件生成,但是大小为0,无法正常保存 解决方法 说明版本、流程等都没有问题,因为有报OutOfMemory的问题,猜测问题可能是机器配置问题?换个服务器试试。 但换了个好点的服务器仍然不行,但是另一台服务器因为cuda版本高,换了高版本的tensorrt就可以了。。。但需注意:cuda版本和tensorrt版本需一致,否则拿回来的模型可能会出现加载不了的问题.显卡不同也可能会有这个问题。 最终确定是版本问题,tensorrt7.0.0.11就是会偶尔出现这个问题,无法正常保存,换个高版本就可以。低版本会有其他问题,tensorrt5、6都不推荐使用 点此参考
======================================================== trtexec error while loading shared libraries: libcudart.so.10.2: cannot open… 解决方法 tensorrt和cuda版本不对,用nvcc -V查看版本,重新装一下tensorrt就好了
======================================================== Reading engine from file reid_1_3_256_128_static_view1.trt [TensorRT] ERROR: INVALID_ARGUMENT: getPluginCreator could not find plugin InstanceNormalization_TRT version 1 [TensorRT] ERROR: safeDeserializationUtils.cpp (322) - Serialization Error in load: 0 (Cannot deserialize plugin since corresponding IPluginCreator not found in Plugin Registry) [TensorRT] ERROR: INVALID_STATE: std::exception [TensorRT] ERROR: INVALID_CONFIG: Deserialize the cuda engine failed. Traceback (most recent call last): File “demo_trt.py”, line 200, in main(engine_path, image_path, image_size) File “demo_trt.py”, line 129, in main with get_engine(engine_path) as engine, engine.create_execution_context() as context: AttributeError: enter 解决 Finally, I found need to init the plugin first.
trt.init_libnvinfer_plugins(trt.Logger(trt.Logger.WARNING), "")
参考
|