How to Install PyTorch with CUDA Using uv
On Windows, uv add torch gives a PyTorch that can't use an NVIDIA GPU, because PyPI's Windows build has no CUDA. PyTorch publishes its CUDA builds on its own package index, and uv can take them from there for Windows only. This guide sets that up for CUDA 13.2 with PyTorch 2.15.0, and checks what each operating system gets.
Syntax
[tool.uv.sources]
<package> = [
{ index = "<index name>", marker = "<which systems>" },
]
[[tool.uv.index]]
name = "<index name>"
url = "https://download.pytorch.org/whl/<CUDA version>"
explicit = true
| Part | What it means |
|---|---|
[tool.uv.sources] | Where uv gets particular packages from, instead of PyPI |
<package> | A package to take from the index: torch, and torchvision with it |
index = "<index name>" | The index to use, by the name it's given below |
marker = "<which systems>" | Uses the index only on the systems the marker matches. sys_platform == 'win32' means Windows |
[[tool.uv.index]] | Declares an extra package index |
url | PyTorch's index for one CUDA version: cu132 is CUDA 13.2 |
explicit = true | Uses the index only for the packages that name it |
The uv guide to PyTorch explains the last one: "We recommend the use of explicit = true to ensure that the index is only used for torch, torchvision, and other PyTorch-related packages, as opposed to generic dependencies like jinja2, which should continue to be sourced from the default index (PyPI)."
The Example
A project named cuda-demo needs PyTorch and torchvision, with CUDA on Windows. Why only Windows? PyTorch's install selector gives, for CUDA 13.2:
- Windows:
pip3 install torch torchvision --index-url https://download.pytorch.org/whl/cu132, PyTorch's own index. - Linux:
pip3 install torch torchvision, plain PyPI, because PyPI's Linux build already uses CUDA 13.2. - macOS: plain PyPI. Macs have no CUDA; PyTorch uses their GPU through MPS.
So the CUDA index goes to Windows alone. I built this on a Mac: every output below is real, and the last step, running it on Windows, is the one I couldn't perform.
Prerequisites
- uv. This guide uses uv 0.13.10 with Python 3.15.2.
- On the Windows PC that will run it: an NVIDIA GPU with its driver installed.
Step 1: Create the Project
uv init --python 3.15 cuda-demo
cd cuda-demo
Initialized project `cuda-demo` at `/Users/you/source/cuda-demo`

Step 2: Point PyTorch at the CUDA Index on Windows
Open pyproject.toml and add these lines at the end:
[tool.uv.sources]
torch = [
{ index = "pytorch-cu132", marker = "sys_platform == 'win32'" },
]
torchvision = [
{ index = "pytorch-cu132", marker = "sys_platform == 'win32'" },
]
[[tool.uv.index]]
name = "pytorch-cu132"
url = "https://download.pytorch.org/whl/cu132"
explicit = true

torch and torchvision both name the index, because the two must come from the same build. The name pytorch-cu132 is only a label: any name works, as long as both places use the same one.
Step 3: Add PyTorch
uv add torch torchvision
Using CPython 3.15.2 interpreter at: /Library/Frameworks/Python.framework/Versions/3.15/bin/python3.15
Creating virtual environment at: .venv
Resolved 33 packages in 2.47s
Built cuda-demo @ file:///Users/you/source/cuda-demo
Prepared 3 packages in 981ms
Installed 14 packages in 323ms
+ cuda-demo==0.1.0 (from file:///Users/you/source/cuda-demo)
+ filelock==4.3.2
+ fsspec==2026.9.0
+ jinja2==3.1.6
+ markupsafe==3.0.4
+ mpmath==1.3.0
+ networkx==3.7
+ numpy==2.5.5
+ pillow==13.0.0
+ setuptools==84.2.1
+ sympy==1.14.0
+ torch==2.15.0
+ torchvision==0.29.2
+ typing-extensions==4.16.0

uv resolved one lockfile for every system and installed the Mac's builds here, since the marker leaves the CUDA index out on macOS. The complete file now:
[project]
name = "cuda-demo"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
authors = [
{ name = "Your Name", email = "you@example.com" }
]
requires-python = ">=3.15"
dependencies = [
"torch>=2.15.0",
"torchvision>=0.29.2",
]
[project.scripts]
cuda-demo = "cuda_demo:main"
[build-system]
requires = ["uv_build>=0.13.10,<0.14.0"]
build-backend = "uv_build"
[tool.uv.sources]
torch = [
{ index = "pytorch-cu132", marker = "sys_platform == 'win32'" },
]
torchvision = [
{ index = "pytorch-cu132", marker = "sys_platform == 'win32'" },
]
[[tool.uv.index]]
name = "pytorch-cu132"
url = "https://download.pytorch.org/whl/cu132"
explicit = true
The authors line holds the name and email from your Git settings.
Step 4: Check What Each System Gets
uv tree shows the project's packages from the lockfile, and --python-platform picks the system to show them for. --depth 1 lists only the project's direct dependencies.
uv tree --python-platform windows --depth 1
Resolved 33 packages in 4ms
cuda-demo v0.1.0
├── torch v2.15.0+cu132
└── torchvision v0.29.2+cu132
uv tree --python-platform macos --depth 1
Resolved 33 packages in 5ms
cuda-demo v0.1.0
├── torch v2.15.0
└── torchvision v0.29.2
uv tree --python-platform linux --depth 1
Resolved 33 packages in 6ms
cuda-demo v0.1.0
├── torch v2.15.0
└── torchvision v0.29.2

Windows gets torch v2.15.0+cu132: the +cu132 part marks PyTorch's CUDA 13.2 build. macOS and Linux get PyPI's torch v2.15.0. The commands work unchanged in PowerShell.
The CUDA build is big: the Windows file for torch 2.15.0+cu132 is 2.12 GB, against 126.7 MB for PyPI's Windows build without CUDA.
Step 5: Run It on Windows
On the Windows PC, in the project folder, install what the lockfile lists and ask PyTorch whether it can reach the GPU:
uv sync
uv run python -c "import torch; print(torch.__version__); print(torch.cuda.is_available())"
uv sync installs exactly what uv.lock lists for this system. PyTorch's install page describes the second line's check as the way "to check if your GPU driver and CUDA is enabled and accessible by PyTorch". I couldn't run this step: this guide was written on a Mac, which has no CUDA.
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
Leaving out the marker | On a Mac, uv add torch failed: Distribution `torch==2.15.0+cu132 @ registry+https://download.pytorch.org/whl/cu132` can't be installed because it doesn't have a source distribution or wheel for the current platform | Add marker = "sys_platform == 'win32'", as Fixed: Distribution torch==2.15.0+cu132 can't be installed shows |
Pointing only torch at the index | torchvision comes from PyPI, a different build | List both, as Step 2 does |
Leaving out explicit = true | uv may look for other packages on PyTorch's index too | Keep explicit = true |
FAQ
Which CUDA version should I pick?
PyTorch's selector offers CUDA 13.2 and 13.4 for PyTorch 2.15.0. CUDA 13.2 is the one PyPI's Linux build uses; for 13.4, use cu134 in the URL.
Does a Mac ever get the CUDA build?
No. PyTorch's CUDA index has no macOS builds: its torch 2.15.0+cu132 files are for Linux and Windows only. A Mac uses its GPU through MPS, which PyPI's build already has.
Conclusion
Two [tool.uv.sources] entries with marker = "sys_platform == 'win32'" and one explicit [[tool.uv.index]] for cu132 made the lockfile list torch v2.15.0+cu132 and torchvision v0.29.2+cu132 for Windows, while macOS and Linux kept PyPI's torch v2.15.0.
Additional Resources
- Using uv with PyTorch — every PyTorch index and how to choose one per system.
- PyTorch: Get Started — the install selector for each system and CUDA version.
- uv: package indexes — how
[[tool.uv.index]]andexplicitwork.
