Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions docs/guides/integration/pytorch.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ CUDA).

!!! note

Some of the features outlined in this guide require uv version 0.5.3 or later. If you're using an
older version of uv, we recommend upgrading prior to configuring PyTorch.
Some of the features outlined in this guide require uv version 0.5.3 or later. We recommend upgrading prior to configuring PyTorch.

## Installing PyTorch

Expand Down Expand Up @@ -396,3 +395,28 @@ To use the same workflow with uv, replace `pip3` with `uv pip`:
```shell
$ uv pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
```

## Automatic backend selection

In [preview](../../reference/settings.md#preview), uv can automatically select the appropriate
PyTorch index at runtime by inspecting the system configuration via `--torch-backend=auto` (or
`UV_TORCH_BACKEND=auto`):

```shell
$ UV_TORCH_BACKEND=auto uv pip install torch
```

When enabled, uv will query for the installed CUDA driver version and use the most-compatible
PyTorch index for all relevant packages (e.g., `torch`, `torchvision`, etc.). If no such CUDA driver
is found, uv will fall back to the CPU-only index. uv will continue to respect existing index
configuration for any packages outside the PyTorch ecosystem.

To select a specific backend (e.g., `cu126`), set `--torch-backend=cu126` (or
`UV_TORCH_BACKEND=cu126`).

At present, `--torch-backend` is only available in the `uv pip` interface, and only supports
detection of CUDA drivers (as opposed to other accelerators like ROCm or Intel GPUs).

As `--torch-backend` is a preview feature, it should be considered experimental and is not governed
by uv's standard [versioning policy](../../reference/policies/versioning.md). `--torch-backend` may
change or be removed entirely in future versions of uv.
Loading