NVIDIA / trt-samples-for-hackathon-cn

Simple samples for TensorRT programming
Apache License 2.0
1.48k stars 337 forks source link

OnnxGraphSurgeon中readme.md图片路径名不对 #11

Closed JQZhai closed 2 years ago

jedibobo commented 2 years ago

这个不是大问题,有个问题是05的在onnx-runtime>=1.9和Onnx-Graphsurgeon==0.3.15时无法通过,会报出: [W] Inference failed. You may want to try enabling partitioning to see better results. Note: Error was: This ORT build has ['TensorrtExecutionProvider', 'CUDAExecutionProvider', 'CPUExecutionProvider'] enabled. Since ORT 1.9, you are required to explicitly set the providers parameter when instantiating InferenceSession. For example, onnxruntime.InferenceSession(..., providers=['TensorrtExecutionProvider', 'CUDAExecutionProvider', 'CPUExecutionProvider'], ...)

解决方案: python3 -m pip install -U onnx_graphsurgeon --index-url https://pypi.ngc.nvidia.com 目前我在0.3.16版本测试没有问题。

jedibobo commented 2 years ago

改好的Readme

README.md

wili-65535 commented 2 years ago

嗯嗯,onnxruntime在1.9 版本之后强制要求给定 provider,这个报错信息出现在 /usr/local/lib/python3.8/dist-packages/onnxruntime/capi/onnxruntime_inference_collection.py 的第 361 行。

我之前的解决方法很粗暴,就在这个文件的第 335 行:

self._create_inference_session(providers, provider_options, disabled_optimizers)

改成

self._create_inference_session(['CUDAExecutionProvider'], provider_options, disabled_optimizers)

问题就解决了。

缺点是这样以后 onnxruntime 只能使用 CUDA 后端,不过我一般用 onnxruntime 来比较他跟原生 TensorRT 的速度和精度,而不用它来调用其他后端做计算,这样做足够了。

我试了你的方案,也解决了问题,感谢!