Registry / ai-ml / torch-directml

torch-directml

JSON →
library0.2.5.dev240914pypypiunverified

Provides a DirectML backend for hardware acceleration in PyTorch, enabling GPU acceleration on Windows devices with DirectX 12 compatible GPUs (including AMD, Intel, and NVIDIA). Current version is 0.2.5.dev240914, with preview releases following a monthly cadence.

pip install torch-directml
INSTALL
IMPORT
SIG · TORCH-DIRECTML
T
torch-directml
ai-mlpythonv0.2.5.dev240914
Install
87.8s avg
Import
Disk
5197MB
Pass rate
4/ 10
Env Coverage4 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.2.5.dev240914 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✕ build_error
✓ 90.7s
py 3.11
✕ build_error
✓ 85s
py 3.12
✕ build_error
✓ 78.9s
py 3.13
✕ build_error
✕ build_error
py 3.9
✕ build_error
✓ 96.8s
5197MB installed
● package 5197MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

torch_directml
import torch_directml
import torch_directml

Basic setup: import torch_directml, get the default DirectML device, move a tensor to it.

import torch import torch_directml device = torch_directml.device() tensor = torch.tensor([1.0, 2.0, 3.0]).to(device) print(tensor.device)
Debug
Known issues
gotchatorch-directml does not support CUDA APIs; use torch_directml.device() instead of torch.device('cuda').
fix
Use `torch_directml.device()` or `torch_directml.device(torch_directml.device_count() - 1)` for specific devices.
affects: all
deprecatedThe `dml` module alias is deprecated; always import `torch_directml`.
fix
Use `import torch_directml` instead of `import dml`.
affects: <=0.2.4
gotchaOnly Windows is supported; Linux/WSL is not supported for torch-directml (separate package tensorflow-directml may work for TF).
fix
Run on Windows 10/11 with DirectX 12 capable GPU.
affects: all
Upgrade
Version history
0.2.5.dev240914latest on PyPI · released Sep 15, 2024
Audit
Dependencies
torchrequiredRequired; torch-directml is a backend plugin for PyTorch.
Agent activity
53 hits · last 30 days
node
44
OpenAI (training)
1
Resources