【已解決】運行onnxruntime-gpu時遇到RuntimeError問題
- 問題描述
在使用onnxruntime進行模型推理時希望使用GPU進行加速,但運行時出現RuntimeError
具體報錯如下:
*************** EP Error ***************
EP Error D:\a_work\1\s\onnxruntime\python\onnxruntime_pybind_state.cc:891 onnxruntime::python::CreateExecutionProviderInstance CUDA_PATH is set but CUDA wasnt able to be loaded. Please install the correct version of CUDA andcuDNN as mentioned in the GPU requirements page (https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html#requirements), make sure they're in the PATH, and that your GPU is supported.
when using ['CUDAExecutionProvider']
Falling back to ['CUDAExecutionProvider', 'CPUExecutionProvider'] and retrying.
2. 解決問題都干了什么
- 首先把cunda安裝目錄都添加到了path 環境變量里
- 重新安裝了onnxruntime-gpu == 1.18.1 # 從原來的1.18.0===》更改為1.18.1,沒啥用可能
- 卸載了onnxruntime == 1.18.0 ,運行報了新錯誤,pydoc.ErrorDuringImport: problem in cosyvoice.flow.flow_matching - ImportError: cannot import name 'InferenceSession' from 'onnxruntime' (unknown location)
- 然后直接安裝 onnxruntime-gpu 最新版 ,沒有指定版本,默認是1.19.2,成功啟動
其他可能有用:
- GPU型號與onnxruntime不兼容:你的顯卡是NVIDIA GeForce RTX 4070,可能不在onnxruntime支持的GPU列表中。你可以查看onnxruntime的官方文檔,確認你的GPU型號是否被支持。如果不支持,你可能需要降級你的GPU驅動或者更換一個受支持的GPU。
- CUDA\v11.8 + cudnn-windows-x86_64-8.9.7.29 + onnxruntime-gpu == 1.18.1
3. 還遇到過問題,遇到的太多了,淚目,太難了
- 顯卡支持的cuda版本不支持
-
一直報沒有matcha這個模塊
-
onnx-time這個版本不匹配
浙公網安備 33010602011771號