torch-directml
A DirectML backend for hardware acceleration in PyTorch.
What it is and what it does
torch-directml is a PyTorch backend plugin that routes computation to DirectML, a hardware-accelerated DirectX 12 library maintained by Microsoft. It allows PyTorch models to train and run inference on a broad range of GPUs—AMD, Intel, NVIDIA, and Qualcomm—without requiring CUDA or vendor-specific drivers, making it particularly useful on Windows and Windows Subsystem for Linux systems where CUDA may not be available or practical.
The package is in active development (classified as Alpha) and depends on torch and torchvision. It provides pre-built wheels for Python 3.7 through 3.12 on both Windows and Linux, though operator coverage is still expanding. The project collects GPU device info and CPU fallback data to improve operator support, and it is maintained by Microsoft with an open issue tracker and active community feedback channels.
Use it for:
- Train PyTorch models on Windows machines with AMD or Intel GPUs where CUDA is unavailable.
- Run inference on DirectX 12-capable hardware without installing vendor-specific GPU drivers.
- Prototype machine learning on consumer-grade GPUs (AMD, Intel, Qualcomm) before deploying to NVIDIA infrastructure.
- Accelerate PyTorch workloads in Windows Subsystem for Linux environments with GPU support.
- Evaluate multi-vendor GPU compatibility for a PyTorch application without rewriting code.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Enables PyTorch to use DirectML for GPU acceleration on DirectX 12-compatible hardware from AMD, Intel, NVIDIA, and Qualcomm.
Yes, if you are on Windows or WSL with a DirectX 12-capable GPU and need PyTorch acceleration without CUDA. The package is actively maintained, has no known vulnerabilities, carries a permissive MIT license, and is backed by Microsoft. However, operator coverage is still developing—verify that your specific PyTorch operations are supported via the operator roadmap before committing to production use.
Install
torch-directml on PyPI
pip
pip install torch-directmluv
uv add torch-directmlpoetry
poetry add torch-directmlInstalling torch-directml
Before you install
Medium install friction due to platform-specific wheels (Windows and Linux only) and requirement for torch and torchvision as runtime dependencies. Package is actively maintained with recent commits and no known vulnerabilities.
License in practice
MIT license permits commercial and private use with minimal restrictions; you may use, modify, and distribute the package freely provided you include the license notice.
Quickstart
pip install torch-directml
import torch
device = torch.device('dml')
tensor = torch.randn(10, 10, device=device)
Requires DirectX 12-compatible GPU hardware and Windows or Windows Subsystem for Linux; torch and torchvision must be installed first.
Verify before relying
- Completeness of operator coverage—the fact sheet notes active development and an operator roadmap but does not specify how many core PyTorch operations are currently supported.
- Performance characteristics compared to native CUDA or other backends on specific hardware.
- Data collection scope and opt-out mechanisms for GPU device info and CPU fallback operators mentioned in the privacy notice.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.7) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | 2 — torch, torchvision |
| Maintenance | actively maintained — 698 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 88,718/month — #13,709 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: torch_directml-0.2.5.dev240914-cp310-cp310-manylinux2010_x86_64.whl; torch_directml-0.2.5.dev240914-cp310-cp310-win_amd64.whl; torch_directml-0.2.5.dev240914-cp311-cp311-manylinux2010_x86_64.whl; torch_directml-0.2.5.dev240914-cp311-cp311-win_amd64.whl; torch_directml-0.2.5.dev240914-cp312-cp312-manylinux2010_x86_64.whl; torch_directml-0.2.5.dev240914-cp312-cp312-win_amd64.whl; torch_directml-0.2.5.dev240914-cp38-cp38-manylinux2010_x86_64.whl; torch_directml-0.2.5.dev240914-cp38-cp38-win_amd64.whl; torch_directml-0.2.5.dev240914-cp39-cp39-manylinux2010_x86_64.whl; torch_directml-0.2.5.dev240914-cp39-cp39-win_amd64.whl
Keywords: pytorch, plugin, machine learning, directml, directx, d3d12
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
torchPyTorch provides GPU-accelerated tensor…
permissive · top 1,000 on PyPI
nvidia-cudnn-cu11Provides cuDNN runtime libraries for…
unclear · top 5,000 on PyPI
transformer-engine-cu12Accelerates Transformer model training and…
unclear · top 15,000 on PyPI
transformer-engine-cu13Accelerates Transformer model training and…
unclear · top 15,000 on PyPI
nvidia-cudnn-cu12Provides cuDNN runtime libraries for…
unclear · top 1,000 on PyPI
transformer-engineTransformer Engine accelerates Transformer…
unclear · top 15,000 on PyPI
nvidia-cuda-runtime-cu12Provides NVIDIA CUDA 12 runtime native…
unclear · top 1,000 on PyPI
torchtitantorchtitan is a PyTorch-native platform for…
permissive · top 15,000 on PyPI
nvidia-cudnn-cu13Provides cuDNN runtime libraries for…
unclear · top 1,000 on PyPI
nvidia-cuda-runtime-cu11Provides CUDA 11 runtime native libraries for…
unclear · top 5,000 on PyPI