onnx python 推理错误

ValueError: could not broadcast input array from shape (150528,) into shape (602112,)
[TensorRT] ERROR: 1: [hardwareContext.cpp::terminateCommonContext::141] Error Code 1: Cuda Runtime (invalid device context)
[TensorRT] INTERNAL ERROR: [defaultAllocator.cpp::free::85] Error Code 1: Cuda Runtime (invalid argument)
Segmentation fault (core dumped)

在使用 python onnx 推理时候遇到该问题。

显然该问题是因为我更新了 onnx 版本, 而 onnxruntime 版本还是旧的,故存在不匹配问题。

因此解决手段:卸载并安装需要的onnxruntime版本即可。

pip uninstall onnxruntime

pip install onnxruntime

然后删除旧的trt文件。重新生成 onnx 文件 和 trt 文件即可。


版权声明:本文为hymn1993原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。