{"id":24144,"library":"onnxruntime-directml","title":"ONNX Runtime DirectML","description":"ONNX Runtime with DirectML execution provider for hardware-accelerated ML inference on Windows devices with DirectX 12 compatible GPUs. Version 1.24.4 requires Python >=3.11 and is maintained by Microsoft. Release cadence follows ONNX Runtime releases.","status":"active","version":"1.24.4","language":"python","source_language":"en","source_url":"https://github.com/microsoft/onnxruntime","tags":["onnx","onnxruntime","directml","machine-learning","inference","windows"],"install":[{"cmd":"pip install onnxruntime-directml","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Required for tensor operations in ONNX Runtime.","package":"numpy","optional":false},{"reason":"Used for serializing ONNX models.","package":"protobuf","optional":false},{"reason":"Required for shape inference in some operators.","package":"sympy","optional":true}],"imports":[{"note":"Onnxruntime-directml does not expose its own InferenceSession; it uses the standard onnxruntime session. DirectML is enabled via session options.","wrong":"from onnxruntime_directml import InferenceSession","symbol":"InferenceSession","correct":"from onnxruntime import InferenceSession"},{"note":"SessionOptions is in the onnxruntime package, not a separate directml package.","wrong":"import onnxruntime_directml","symbol":"SessionOptions","correct":"from onnxruntime import SessionOptions"}],"quickstart":{"code":"import onnxruntime\nfrom onnxruntime import InferenceSession, SessionOptions\n\n# Enable DirectML execution provider\noptions = SessionOptions()\noptions.enable_training = False\nproviders = ['DmlExecutionProvider', 'CPUExecutionProvider']\nsession = InferenceSession('model.onnx', options, providers=providers)\n# Run inference\nimport numpy as np\ninput_name = session.get_inputs()[0].name\nresult = session.run(None, {input_name: np.random.randn(1, 3, 224, 224).astype(np.float32)})","lang":"python","description":"Basic inference using DirectML provider. Ensure model.onnx exists and is compatible."},"warnings":[{"fix":"Upgrade Python to 3.11 or later, or use an older onnxruntime-directml version (but note older versions may lack features).","message":"Python 3.11 minimum required as of version 1.24.x. Older Python versions are unsupported.","severity":"breaking","affected_versions":">=1.24.0"},{"fix":"Check platform before using DirectML: import sys; if not sys.platform.startswith('win'): raise RuntimeError('DirectML requires Windows').","message":"DirectML execution provider requires Windows 10/11 with DirectX 12 GPU. It will not work on Linux or macOS. Trying to use DmlExecutionProvider on unsupported OS raises an error.","severity":"gotcha","affected_versions":"all"},{"fix":"Use Liberica JDK 8 or 11 as the Java runtime for QuickSight.","message":"Using Oracle JDK is deprecated; only Liberica JDK is fully supported. The default JDK download in some documentation points to Oracle, which may cause compatibility issues.","severity":"deprecated","affected_versions":"all"},{"fix":"Always place DirectML provider first: providers=['DmlExecutionProvider', 'CPUExecutionProvider'].","message":"Manually specifying the execution provider order can cause performance degradation if CPU provider is placed before DirectML. Setting providers list correctly is essential.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Uninstall onnxruntime and install onnxruntime-directml: pip uninstall onnxruntime && pip install onnxruntime-directml.","cause":"The installed onnxruntime Python package does not include DirectML support. Only onnxruntime-directml includes the DML provider.","error":"onnxruntime.capi.onnxruntime_pybind11_state.NotImplemented: DML provider is not supported in this build."},{"fix":"Install the latest Visual C++ Redistributable from Microsoft (https://aka.ms/vs/17/release/vc_redist.x64.exe) and ensure DirectX 12 is available.","cause":"Missing Visual C++ Redistributable or DirectX runtime on the system.","error":"RuntimeError: Dll registration failed. The specified module could not be found."},{"fix":"Verify the model file with onnx.checker.check_model() after loading with onnx.load(). Ensure protobuf version is compatible (protobuf 3.x recommended).","cause":"The model file is corrupt or not in ONNX format, or the protobuf library version mismatch.","error":"onnxruntime.capi.onnxruntime_pybind11_state.Fail: Load model from <path> failed: File is not a valid ONNX protobuf."}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}