docs/en/integrations/amd.md
Ultralytics supports training, validation, and inference on compatible AMD GPUs through
PyTorch ROCm. PyTorch intentionally exposes ROCm devices through the same
torch.cuda Python API used by CUDA, so Ultralytics does not need a separate rocm device type for native PyTorch
models. Install a ROCm build of PyTorch, then select an AMD GPU with the standard device=0 or device=cuda:0 syntax.
AMD also offers inference technologies that are separate from PyTorch ROCm. Support for one AMD product does not imply support for every AMD runtime or accelerator.
This table describes the Ultralytics Python package used for training, validation, export, and prediction.
| AMD product or runtime | Ultralytics support | Usage or status |
|---|---|---|
| AMD Instinct and supported Radeon GPUs with ROCm | ✅ | Train, validate, and run native PyTorch models with device=0 or device=cuda:0. |
| Multi-GPU ROCm | ✅ | Use device=0,1 or device=[0, 1]; distributed execution follows the installed PyTorch ROCm stack. |
| ROCm Automatic Mixed Precision (AMP) | ⚠️ | Available when the installed PyTorch and ROCm versions pass Ultralytics AMP checks; use amp=False if incompatible. |
| ONNX export | ✅ | Export is supported, but the ONNX file does not by itself provide an AMD-accelerated runtime. |
| MIGraphX inference | 🚧 | Not available in the current Python package; implementation work is tracked in PR #24137. |
| AMD Docker image and AMD hardware CI | 🚧 | Also tracked in PR #24137, not provided by ROCm device selection alone. |
| Windows DirectML | ❌ Python | No DirectML training or prediction backend in the Python package. |
| Ryzen AI NPU | ❌ | No native Ultralytics NPU integration; external ONNX/Vitis AI workflows are community-managed. |
| AMD CPUs | ✅ CPU | Use device=cpu; this is standard CPU execution, not an AMD-specific acceleration backend. |
!!! note "Check AMD and PyTorch compatibility first"
ROCm availability depends on the exact GPU, operating system, ROCm version, and PyTorch build. Confirm your hardware
in AMD's [ROCm compatibility matrix](https://rocm.docs.amd.com/en/latest/compatibility/compatibility-matrix.html)
before installing. Ultralytics cannot add support for a device that the installed PyTorch ROCm build does not expose.
The ROCm build of PyTorch uses HIP internally but deliberately reuses the torch.cuda interfaces. For example,
torch.cuda.is_available(), torch.cuda.device_count(), and torch.cuda.get_device_name() work with supported AMD GPUs.
This design lets the same Ultralytics training path serve NVIDIA CUDA and AMD ROCm without a duplicate backend.
See the official PyTorch HIP semantics for details.
!!! important
In the Python package, use `device=0` or `device=cuda:0` for PyTorch ROCm. Do not use `device=rocm:0`; `rocm` is not
a PyTorch device type.
Verify that your operating system and GPU appear in the ROCm compatibility matrix.
Use the PyTorch installation selector to choose the ROCm build matching your installed ROCm version.
Install Ultralytics after PyTorch:
pip install ultralytics
Verify that PyTorch sees the AMD GPU:
import torch
print(torch.cuda.is_available())
print(torch.cuda.get_device_name(0))
print(torch.version.hip)
torch.cuda.is_available() should return True, the device name should identify your AMD GPU, and torch.version.hip
should report the HIP version supplied by the ROCm build.
Use the same device arguments as standard Ultralytics Train mode.
!!! example "ROCm Training"
=== "Python"
```python
from ultralytics import YOLO
model = YOLO("yolo26n.pt")
# Train on the first AMD GPU exposed by PyTorch ROCm
results = model.train(data="coco8.yaml", epochs=100, imgsz=640, device=0)
# Train across two AMD GPUs
results = model.train(data="coco8.yaml", epochs=100, imgsz=640, device=[0, 1])
```
=== "CLI"
```bash
# Train on one AMD GPU
yolo detect train data=coco8.yaml model=yolo26n.pt epochs=100 imgsz=640 device=0
# Train across two AMD GPUs
yolo detect train data=coco8.yaml model=yolo26n.pt epochs=100 imgsz=640 device=0,1
```
Validation and prediction use the same device selection:
yolo detect val model=path/to/best.pt data=coco8.yaml device=0
yolo predict model=path/to/best.pt source=path/to/image.jpg device=0
Ultralytics enables AMP by default and compares full-precision and mixed-precision results before training. If the check
detects incompatible results, AMP is disabled to prevent NaN losses or zero-mAP training. ROCm AMP behavior can change
with the PyTorch and ROCm versions, so use amp=False when troubleshooting a stack-specific failure:
yolo detect train data=coco8.yaml model=yolo26n.pt device=0 amp=False
MIGraphX is AMD's graph-optimization and inference runtime. Native MIGraphX model loading is not included in the current Ultralytics Python package. The active implementation, AMD container, dependencies, tests, and documentation are tracked together in PR #24137. Until that work merges and receives AMD hardware validation, exporting an ONNX model should not be described as native MIGraphX support in the Python package.
The Ultralytics Python package has no DirectML backend for Windows training or prediction. DirectML is distinct from
ROCm, and a working ROCm environment does not enable device=directml.
Ryzen AI NPUs are not exposed through PyTorch ROCm and are not native Ultralytics devices. Community workflows may export YOLO models to ONNX and run them with AMD's external Ryzen AI or Vitis AI tools, but that runtime, conversion, and hardware compatibility are outside the supported Ultralytics execution path.
torch.cuda.is_available() return False on my AMD system?The installed PyTorch package may be a CPU or CUDA build, or the GPU may not be supported by the active ROCm stack. Install the matching ROCm build from the PyTorch selector and verify the GPU against AMD's compatibility matrix.
This is expected. PyTorch ROCm intentionally uses the torch.cuda API and CUDA-style device strings for Python
compatibility. The model still executes through HIP and ROCm on the AMD GPU.
No. ONNX is a portable model format. Accelerated execution still requires a compatible runtime, and native MIGraphX, DirectML, and Ryzen AI NPU backends are not included in the current Ultralytics Python package.
Use a compatible PyTorch ROCm build with device=0 or device=cuda:0 for supported AMD GPU training, validation, and
inference. Treat MIGraphX, DirectML, and Ryzen AI NPU as separate capabilities: none is enabled merely by installing
ROCm or exporting an ONNX model.