From 990c59ddb684c7b717c0c477d7ed23b83db9b907 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Tue, 29 Apr 2025 15:13:13 -0400 Subject: [PATCH] Add ROCm example to the PyTorch guide (#13200) ## Summary Closes https://github.com/astral-sh/uv/issues/13197#issuecomment-2839707240. --- docs/guides/integration/pytorch.md | 51 +++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 8 deletions(-) diff --git a/docs/guides/integration/pytorch.md b/docs/guides/integration/pytorch.md index 6e5b03136..ca3d3e653 100644 --- a/docs/guides/integration/pytorch.md +++ b/docs/guides/integration/pytorch.md @@ -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]]