Skip to content

Instantly share code, notes, and snippets.

@TeamDman
Last active May 1, 2025 22:26
Show Gist options
  • Select an option

  • Save TeamDman/f05ec9944b956e21fd1ec120af6adbad to your computer and use it in GitHub Desktop.

Select an option

Save TeamDman/f05ec9944b956e21fd1ec120af6adbad to your computer and use it in GitHub Desktop.
Behold, a consistent way to install PyTorch on Windows using uv
# https://gist.github.com/TeamDman/f05ec9944b956e21fd1ec120af6adbad
uv sync
$index_url = "https://download.pytorch.org/whl/cu128"
$packages = @(
"torch",
"torchvision",
"torchaudio"
)
$to_add = @(
"markupsafe<3.0.2" # fuck python package management, windows fails without this
# https://github.com/astral-sh/uv/issues/11532#issuecomment-2660933703
# error: Distribution `markupsafe==3.0.2 @ registry+https://download.pytorch.org/whl/cu128` can't be installed because it doesn't have a source distribution or wheel for the current platform
)
foreach ($package in $packages) {
Write-Host "Checking for '$package'"
$data = pip3 index versions "$package" --index-url "$index_url" --json | ConvertFrom-Json
$package_version = "$package==$($data.latest)"
$to_add += @($package_version)
Write-Host "Found $package_version"
}
Write-Host "uv add $to_add" --index-url "$index_url"
uv add @to_add --index-url "$index_url"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment