里奥呐 2024-07-04 18:53 采纳率: 0%
浏览 263

运行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.


RuntimeError: 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.

显卡配置:NVIDIA GeForce RTX 4070

运行环境如下:
python 3.8.19
CUDA 12.1
cudnn 8.9.2.26
onnxruntime 1.18.1

已经自查过CUDA安装路径已经环境变量的配置,大体上应该没有问题,有没有 大能 能帮看看,具体是什么原因。

  • 写回答

1条回答 默认 最新

  • 专家-赤兔[在线] 优质创作者: 编程框架技术领域 2024-07-04 18:53
    关注

    引自免费微信小程序:皆我百晓生

    根据你提供的错误信息,问题可能出在以下几个方面:

    1. CUDA版本与onnxruntime不兼容:虽然你安装了CUDA 12.1和cudnn 8.9.2.26,但onnxruntime可能不支持这个版本。你可以尝试安装一个较旧的CUDA版本,比如CUDA 11或者CUDA 10看是否解决问题。注意安装新版本的CUDA时,需要卸载旧版本。
    2. GPU型号与onnxruntime不兼容:你的显卡是NVIDIA GeForce RTX 4070,可能不在onnxruntime支持的GPU列表中。你可以查看onnxruntime的官方文档,确认你的GPU型号是否被支持。如果不支持,你可能需要降级你的GPU驱动或者更换一个受支持的GPU。
    3. 环境变量配置问题:虽然你已经检查过CUDA安装路径和环境变量的配置,但仍然有可能存在配置错误。你可以通过运行nvcc --version在命令行中检查CUDA是否正确安装,运行pip list查看是否包含正确的onnxruntime版本。同时,确认CUDA的路径是否已经正确添加到系统的PATH环境变量中。
    4. 其他依赖问题:确认你的环境中是否缺少其他必要的依赖库,比如是否有正确的Visual C++版本等。你可以查阅onnxruntime的官方文档,确认所有必要的依赖都已经正确安装。

    关于你的具体问题,我建议首先尝试降级CUDA版本,看看是否能解决问题。如果问题仍然存在,你可能需要考虑更换一个受支持的GPU或者寻求更专业的技术支持。此外,你也可以尝试在相关的技术社区或者论坛发帖求助,可能会有其他遇到类似问题的用户分享他们的解决方案。

    评论 编辑记录

报告相同问题?

问题事件

  • 创建了问题 7月4日