Add ROCm example to the PyTorch guide (#13200)

## Summary

Closes
https://github.com/astral-sh/uv/issues/13197#issuecomment-2839707240.
This commit is contained in:
Charlie Marsh 2025-04-29 15:13:13 -04:00 committed by GitHub
parent 241b013600
commit 990c59ddb6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -197,6 +197,11 @@ Next, update the `pyproject.toml` to point `torch` and `torchvision` to the desi
torchvision = [
{ index = "pytorch-rocm", marker = "sys_platform == 'linux'" },
]
# ROCm6 support relies on `pytorch-triton-rocm`, which should also be installed from the PyTorch index
# (and included in `project.dependencies`).
pytorch-triton-rocm = [
{ index = "pytorch-rocm", marker = "sys_platform == 'linux'" },
]
```
=== "Intel GPUs"
@ -212,10 +217,10 @@ Next, update the `pyproject.toml` to point `torch` and `torchvision` to the desi
torchvision = [
{ index = "pytorch-xpu", marker = "sys_platform == 'linux' or sys_platform == 'win32'" },
]
# Intel GPU support relies on `pytorch-triton-xpu` on Linux, which should also be installed from the PyTorch index
# Intel GPU support relies on `pytorch-triton-xpu`, which should also be installed from the PyTorch index
# (and included in `project.dependencies`).
pytorch-triton-xpu = [
{ index = "pytorch-xpu", marker = "sys_platform == 'linux'" },
{ index = "pytorch-xpu", marker = "sys_platform == 'linux' or sys_platform == 'win32'" },
]
```
@ -227,8 +232,8 @@ name = "project"
version = "0.1.0"
requires-python = ">=3.12.0"
dependencies = [
"torch>=2.6.0",
"torchvision>=0.21.0",
"torch>=2.7.0",
"torchvision>=0.22.0",
]
[tool.uv.sources]
@ -285,8 +290,8 @@ url = "https://download.pytorch.org/whl/cu128"
explicit = true
```
Similarly, the following configuration would use PyTorch's Intel GPU builds on Windows and Linux,
and CPU-only builds on macOS (by way of falling back to PyPI):
Similarly, the following configuration would use PyTorch's AMD GPU builds on Linux, and CPU-only
builds on Windows and macOS (by way of falling back to PyPI):
```toml
[project]
@ -296,7 +301,37 @@ requires-python = ">=3.12.0"
dependencies = [
"torch>=2.7.0",
"torchvision>=0.22.0",
"pytorch-triton-xpu>=3.3.0 ; sys_platform == 'linux'",
"pytorch-triton-rocm>=3.3.0 ; sys_platform == 'linux'",
]
[tool.uv.sources]
torch = [
{ index = "pytorch-rocm", marker = "sys_platform == 'linux'" },
]
torchvision = [
{ index = "pytorch-rocm", marker = "sys_platform == 'linux'" },
]
pytorch-triton-rocm = [
{ index = "pytorch-rocm", marker = "sys_platform == 'linux'" },
]
[[tool.uv.index]]
name = "pytorch-rocm"
url = "https://download.pytorch.org/whl/rocm6.3"
explicit = true
```
Or, for Intel GPU builds:
```toml
[project]
name = "project"
version = "0.1.0"
requires-python = ">=3.12.0"
dependencies = [
"torch>=2.7.0",
"torchvision>=0.22.0",
"pytorch-triton-xpu>=3.3.0 ; sys_platform == 'win32' or sys_platform == 'linux'",
]
[tool.uv.sources]
@ -307,7 +342,7 @@ torchvision = [
{ index = "pytorch-xpu", marker = "sys_platform == 'win32' or sys_platform == 'linux'" },
]
pytorch-triton-xpu = [
{ index = "pytorch-xpu", marker = "sys_platform == 'linux'" },
{ index = "pytorch-xpu", marker = "sys_platform == 'win32' or sys_platform == 'linux'" },
]
[[tool.uv.index]]