Skip to content

Commit 9f8cd92

Browse files
Use positive (rather than negative) markers in PyTorch examples (#11112)
## Summary Maybe slightly controversial because it's more verbose, but we really want to limit these indexes to Linux and Windows, rather than ignoring them on Darwin. E.g., we'd also want to ignore them on other platforms. Further down, I use markers that look like this in the more complete examples, so this feels more consistent.
1 parent 5c0fdfd commit 9f8cd92

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

docs/guides/integration/pytorch.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -142,53 +142,53 @@ Next, update the `pyproject.toml` to point `torch` and `torchvision` to the desi
142142

143143
=== "CUDA 11.8"
144144

145-
PyTorch doesn't publish CUDA builds for macOS. As such, we gate on `platform_system` to instruct uv to ignore
146-
the PyTorch index when resolving for macOS.
145+
PyTorch doesn't publish CUDA builds for macOS. As such, we gate on `platform_system` to instruct uv to use
146+
the PyTorch index on Linux and Windows, but fall back to PyPI on macOS:
147147

148148
```toml
149149
[tool.uv.sources]
150150
torch = [
151-
{ index = "pytorch-cu118", marker = "platform_system != 'Darwin'" },
151+
{ index = "pytorch-cu118", marker = "platform_system == 'Linux' or platform_system == 'Windows'" },
152152
]
153153
torchvision = [
154-
{ index = "pytorch-cu118", marker = "platform_system != 'Darwin'" },
154+
{ index = "pytorch-cu118", marker = "platform_system == 'Linux' or platform_system == 'Windows'" },
155155
]
156156
```
157157

158158
=== "CUDA 12.1"
159159

160-
PyTorch doesn't publish CUDA builds for macOS. As such, we gate on `platform_system` to instruct uv to ignore
161-
the PyTorch index when resolving for macOS.
160+
PyTorch doesn't publish CUDA builds for macOS. As such, we gate on `platform_system` to instruct uv to limit
161+
the PyTorch index to Linux and Windows, falling back to PyPI on macOS:
162162

163163
```toml
164164
[tool.uv.sources]
165165
torch = [
166-
{ index = "pytorch-cu121", marker = "platform_system != 'Darwin'" },
166+
{ index = "pytorch-cu121", marker = "platform_system == 'Linux' or platform_system == 'Windows'" },
167167
]
168168
torchvision = [
169-
{ index = "pytorch-cu121", marker = "platform_system != 'Darwin'" },
169+
{ index = "pytorch-cu121", marker = "platform_system == 'Linux' or platform_system == 'Windows'" },
170170
]
171171
```
172172

173173
=== "CUDA 12.4"
174174

175-
PyTorch doesn't publish CUDA builds for macOS. As such, we gate on `platform_system` to instruct uv to ignore
176-
the PyTorch index when resolving for macOS.
175+
PyTorch doesn't publish CUDA builds for macOS. As such, we gate on `platform_system` to instruct uv to limit
176+
the PyTorch index to Linux and Windows, falling back to PyPI on macOS:
177177

178178
```toml
179179
[tool.uv.sources]
180180
torch = [
181-
{ index = "pytorch-cu124", marker = "platform_system != 'Darwin'" },
181+
{ index = "pytorch-cu124", marker = "platform_system == 'Linux' or platform_system == 'Windows'" },
182182
]
183183
torchvision = [
184-
{ index = "pytorch-cu124", marker = "platform_system != 'Darwin'" },
184+
{ index = "pytorch-cu124", marker = "platform_system == 'Linux' or platform_system == 'Windows'" },
185185
]
186186
```
187187

188188
=== "ROCm6"
189189

190-
PyTorch doesn't publish ROCm6 builds for macOS or Windows. As such, we gate on `platform_system` to instruct uv to
191-
ignore the PyTorch index when resolving for those platforms.
190+
PyTorch doesn't publish ROCm6 builds for macOS or Windows. As such, we gate on `platform_system` to instruct uv
191+
to limit the PyTorch index to Linux, falling back to PyPI on macOS and Windows:
192192

193193
```toml
194194
[tool.uv.sources]
@@ -202,16 +202,16 @@ Next, update the `pyproject.toml` to point `torch` and `torchvision` to the desi
202202

203203
=== "Intel GPUs"
204204

205-
PyTorch doesn't publish Intel GPU builds for macOS. As such, we gate on `platform_system` to instruct uv to ignore
206-
the PyTorch index when resolving for macOS.
205+
PyTorch doesn't publish Intel GPU builds for macOS. As such, we gate on `platform_system` to instruct uv to limit
206+
the PyTorch index to Linux and Windows, falling back to PyPI on macOS:
207207

208208
```toml
209209
[tool.uv.sources]
210210
torch = [
211-
{ index = "pytorch-xpu", marker = "platform_system != 'Darwin'" },
211+
{ index = "pytorch-xpu", marker = "platform_system == 'Linux' or platform_system == 'Windows'" },
212212
]
213213
torchvision = [
214-
{ index = "pytorch-xpu", marker = "platform_system != 'Darwin'" },
214+
{ index = "pytorch-xpu", marker = "platform_system == 'Linux' or platform_system == 'Windows'" },
215215
]
216216
# Intel GPU support relies on `pytorch-triton-xpu` on Linux, which should also be installed from the PyTorch index
217217
# (and included in `project.dependencies`).

0 commit comments

Comments
 (0)