Reference only

ONNX Runtime imports, but GPU execution fails: check providers and sessions

Separate package discovery, runtime providers and the session that actually executes your model.

Use three checkpoints

The onnx package, an ONNX Runtime distribution, and a running inference session are different things. get_available_providers() lists providers in the installed runtime; InferenceSession.get_providers() lists those registered for that session. Neither list proves that this model assigned work to CUDA. Provider priority can use CUDA for capable nodes and CPU for others. Install CUDA requirements Python API Provider priority

python -m pip show onnx onnxruntime onnxruntime-gpu
python -c "import onnxruntime as r; print(r.__version__); print(r.get_available_providers())"

Run this only with the interpreter used by the affected node and a trusted installation. The second command imports native code. If onnxruntime imports but CUDAExecutionProvider is absent, inspect the installed runtime build before changing drivers. If it is present, record the actual node-created session and its initialization log; the available-provider list alone cannot verify device execution.

Route the failure

No import: investigate interpreter selection and installed distributions. Provider-library failure: compare the exact ONNX Runtime release with its documented CUDA/cuDNN major-version requirements and native-library error; the default GPU package build can change by release. CPU fallback: inspect the node's session provider order and initialization log. A session registering both CUDA and CPU may still assign unsupported nodes to CPU; use graph-assignment or profiling evidence when that runtime and wrapper expose it. Model-format or operator failure: preserve the exact error rather than treating it as a driver problem.

Our proposed acceptance check is one small run through the original node, with its session provider list and any available node-assignment or profiling evidence recorded. Test dependency changes in a recoverable copy. If the wrapper does not expose enough evidence, label GPU execution unverified. A successful CPU run is a CPU result, not verified GPU acceleration. No single version pin fits every platform.

Source review completed 2026-09-26. No local package installation, model session, CUDA library load or GPU run was performed.

Didn't solve it?

Check the next possible cause

The same symptom can come from a different cause. Work through these related entries in order.

  1. Fix cv2 imports without stacking OpenCV distributionsNo module named cv2Identify the installed OpenCV flavor before investigating missing modules or native-library loading.
Paste your full log into the error finder

Was this page helpful?

Anonymous. Only a yes/no counter is stored; no account, IP address or device details.

Sources & references

2026-09-26 reviewed ONNX Runtime installation, CUDA provider requirements, provider-priority and Python API documentation; English source review only. No package, model-session or GPU reproduction.

01ONNX Runtime installationSource checked: 2026-09-2602ONNX Runtime CUDA execution providerSource checked: 2026-09-2603ONNX Runtime Python APISource checked: 2026-09-2604ONNX Runtime execution providersSource checked: 2026-09-26

Report an issue · ea931aa0-e623-56b9-9f33-75dfb3fcfeaf