Ogu*_*glu 5 python onnxruntime
import onnxruntime as rt
ort_session = rt.InferenceSession(
"my_model.onnx",
providers=["CUDAExecutionProvider"],
)
Run Code Online (Sandbox Code Playgroud)
当提供程序为.onnxruntime (onnxruntime-gpu 1.13.1) 时(在 Jupyter VsCode env - Python 3.8.15 中)效果["CPUExecutionProvider"]很好 但["CUDAExecutionProvider"]有时(并非总是)会抛出错误:
[W:onnxruntime:Default, onnxruntime_pybind_state.cc:578 CreateExecutionProviderInstance] Failed to create CUDAExecutionProvider. Please reference https://onnxruntime.ai/docs/reference/execution-providers/CUDA-ExecutionProvider.html#requirements to ensure all dependencies are met.
Run Code Online (Sandbox Code Playgroud)
我尝试按照错误中提供的链接进行操作,并在 conda 环境中尝试不同的设置来测试具有各种版本组合的代码。
Ogu*_*glu 11
更换:
import onnxruntime as rt
Run Code Online (Sandbox Code Playgroud)
和
import torch
import onnxruntime as rt
Run Code Online (Sandbox Code Playgroud)
以某种方式完美地解决了我的问题。