skillfed

torch-directml

A DirectML backend for hardware acceleration in PyTorch.

torch-directml v0.2.5.dev240914 88.7K downloads/30d#13,709 on PyPI2,579
Permissive license MIT Active released

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-directml

uv

uv add torch-directml

poetry

poetry add torch-directml

Installing 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

Development Status :: 3 - AlphaIntended Audience :: DevelopersIntended Audience :: EducationIntended Audience :: Science/ResearchLicense :: OSI Approved :: MIT LicenseProgramming Language :: C++Programming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Scientific/EngineeringTopic :: Scientific/Engineering :: Artificial IntelligenceTopic :: Scientific/Engineering :: MathematicsTopic :: Software DevelopmentTopic :: Software Development :: LibrariesTopic :: Software Development :: Libraries :: Python Modules

Tags

pytorch gpu acceleration directmldirectx 12 machine learningpytorch hardware acceleration windowsdirectml pytorch backendgpu training inference pytorchamd intel nvidia gpu pytorchdirectx 12 gpu pytorch
gpu-accelerationdirectmlpytorch-backend

More Software Development packages

Further reading