Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you run a ONNX model on a GPU?

I'm trying to run an ONNX model

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()  )

This prints out

cpu

How can I make it run on my GPU? How can I confirm it's working?

like image 855
djacobs7 Avatar asked Dec 02 '25 08:12

djacobs7


1 Answers

You probably installed the CPU version. Try uninstalling onnxruntime and install GPU version, like pip install onnxruntime-gpu.

Then:

>>> import onnxruntime as ort
>>> ort.get_device()
'GPU'
like image 52
Sergii Dymchenko Avatar answered Dec 08 '25 14:12

Sergii Dymchenko



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!