Deep learning 如何在GPU上运行ONNX模型?

Deep learning 如何在GPU上运行ONNX模型?,deep-learning,onnx,onnxruntime,onnx-coreml,Deep Learning,Onnx,Onnxruntime,Onnx Coreml,我正在尝试运行一个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上运行?如

我正在尝试运行一个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上运行?如何确认它是否正常工作?

您可能安装了CPU版本。尝试卸载onnxruntime并安装GPU版本,如
pip安装onnxruntime GPU

然后:

get_device()命令将支持的设备提供给onnxruntime。 对于CPU和GPU,有不同的运行时包可用

当前,您的onnxruntime环境仅支持CPU,因为您已经安装了onnxruntime的CPU版本

如果您想为GPU构建onnxruntime环境,请使用以下简单步骤

步骤1:卸载当前的onnxruntime

>> pip uninstall onnxruntime
步骤2:安装onnxruntime环境的GPU版本

>>pip install onnxruntime-gpu
>> import onnxruntime as rt
>> rt.get_device()
'GPU'
步骤3:验证设备对onnxruntime环境的支持

>>pip install onnxruntime-gpu
>> import onnxruntime as rt
>> rt.get_device()
'GPU'
步骤4:如果您遇到任何问题,请检查您的cuda和CuDNN版本,它们必须相互兼容。 请参考此链接了解cuda和CuDNN之间的版本兼容性