【已解决】运行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这个版本不匹配
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现