我正在尝试运行一个ONNX模型
import onnxruntime as ort
import onnxruntime.backend
model_path = "model.onnx"
#https://microsoft.github.io/onnxruntime/
ort_sess = ort.InferenceSession(model_path)
print( ort.get_device() )
这将打印出来
cpu
如何让它在我的GPU上运行?我怎样才能确认它在工作呢?
发布于 2020-10-22 09:04:47
您可能安装了CPU版本。尝试卸载onnxruntime并安装GPU版本,如pip install onnxruntime-gpu
。
然后:
>>> import onnxruntime as ort
>>> ort.get_device()
'GPU'
发布于 2021-06-09 20:06:47
get_device()命令为您提供了在运行时支持的设备。对于CPU和GPU,有不同的运行时包可用。
目前,您的onnxruntime环境仅支持CPU,因为您已经安装了onnxruntime的CPU版本。
如果您想为GPU构建一个运行时环境,请使用以下简单步骤。
第1步:卸载当前的onnxruntime
>> pip uninstall onnxruntime
步骤2:安装运行时环境的GPU版本
>>pip install onnxruntime-gpu
第3步:验证设备对onnxruntime环境的支持
>> import onnxruntime as rt
>> rt.get_device()
'GPU'
步骤4:如果您遇到任何问题,请检查您的cuda和CuDNN版本,这两个版本必须相互兼容。要了解cuda和CuDNN之间的版本兼容性,请参阅此链接here。
发布于 2021-11-15 11:44:12
你的onnxruntime gpu版本应该与你的cuda和cudnn版本相匹配,你可以从官方网站:https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html查看它们之间的关系。
https://stackoverflow.com/questions/64452013
复制相似问题