How do I install PyTorch with uv on a cloud GPU?

Install uv with its official installer, create an environment with uv venv --python 3.12, then run uv pip install torch torchvision --torch-backend=auto (or name a CUDA build such as --torch-backend=cu130) and confirm with torch.cuda.is_available() that PyTorch sees the GPU.
Updated 2026-10-29
This guide follows the official uv docs (Using uv with PyTorch, installation, virtual environments, projects and cache) and the PyTorch Get Started page, all read on 2026-10-29. It is for people who rent an NVIDIA GPU such as the RTX 5090 or the other cards listed on /pricing and want a clean, reproducible PyTorch environment without conda.
Step 1: Deploy a Raw GPU and connect
On /deploy, pick an NVIDIA GPU and the Raw GPU option (JupyterLab + CUDA pre-installed, root SSH on a dedicated container). Connect over SSH or open a terminal in JupyterLab.
VRAM need depends on model, precision and workflow; see How much VRAM do I need to run an LLM?. The steps below are the same on each listed card; only the CUDA build you pick in Step 4 depends on the driver.
Step 2: Check the environment first
nvidia-smi # GPU name, driver version and the "CUDA Version" the driver supports
nvcc --version # CUDA toolkit compiler, if installed (PyTorch wheels do not need it)
python3 --version
python3 -c "import torch; print(torch.__version__, torch.version.cuda, torch.cuda.is_available())"
which curl uv
Write down the CUDA Version in the nvidia-smi header; you use it in Step 4. The last python3 line tells you whether a PyTorch is already installed in the system Python. You do not have to remove it: the uv environment below is separate. If curl is missing, install it with your package manager or use the wget line in Step 3.
Step 3: Install uv
The official installer for Linux:
curl -LsSf https://astral.sh/uv/install.sh | sh
# without curl:
# wget -qO- https://astral.sh/uv/install.sh | sh
export PATH="$HOME/.local/bin:$PATH" # where the standalone installer puts uv and uvx
uv --version
To pin a version, the uv docs put it in the URL, for example https://astral.sh/uv/0.13.6/install.sh (0.13.6 was the latest release on 2026-10-29). Update later with uv self update.
Step 4: Create an environment and install a CUDA build of PyTorch
According to the PyTorch Get Started page (read 2026-10-29), the current stable release requires Python 3.11 or later, so ask uv for 3.12. The uv docs say uv downloads that Python for you if it is not on the system:
mkdir -p ~/work && cd ~/work
uv venv --python 3.12
source .venv/bin/activate
uv pip install torch torchvision --torch-backend=auto
According to the uv docs, --torch-backend=auto (or UV_TORCH_BACKEND=auto) queries the installed CUDA driver and uses the most compatible PyTorch index, and falls back to the CPU-only index if no GPU is found. That is why Step 5 checks the result.
To choose the CUDA build yourself, name the index. Pick one that is not newer than the CUDA Version from Step 2:
uv pip install torch torchvision --torch-backend=cu130
# same thing with the index URL that the PyTorch selector shows:
uv pip install torch torchvision --index-url https://download.pytorch.org/whl/cu130
The uv docs note that --torch-backend is available only in the uv pip interface. For help matching the build to the driver, see How to install a specific PyTorch CUDA version on a cloud GPU.
Step 5: Check that PyTorch sees the GPU
python -c "import torch; print(torch.__version__, torch.version.cuda, torch.cuda.is_available()); print(torch.cuda.get_device_name(0)); print((torch.ones(2, device='cuda') * 2).tolist())"
You want three things: a version with a CUDA suffix (the uv docs show the form 2.11.0+cu130), a CUDA version that is not None, and True. If torch.version.cuda prints None, uv installed the CPU-only build: rerun Step 4 with an explicit --torch-backend=cu1XX. If the last line fails with a CUDA kernel error, install a build made for a newer CUDA version that your driver still supports. To watch the GPU while your code runs, see How to check GPU utilization on a cloud GPU.
Step 6 (optional): Pin PyTorch in a uv project
For a project you want to rebuild on the next instance, let uv write a pyproject.toml and a uv.lock. The uv PyTorch guide pins torch and torchvision to one PyTorch index and marks it explicit = true, so other packages still come from PyPI:
uv init myproject && cd myproject
Add this to pyproject.toml:
[[tool.uv.index]]
name = "pytorch-cu130"
url = "https://download.pytorch.org/whl/cu130"
explicit = true
[tool.uv.sources]
torch = [{ index = "pytorch-cu130" }]
torchvision = [{ index = "pytorch-cu130" }]
Then:
uv add torch torchvision
uv run python -c "import torch; print(torch.__version__, torch.cuda.is_available())"
According to the uv projects guide, uv creates the project’s .venv and uv.lock the first time you run uv run, uv sync or uv lock, and uv.lock is a cross-platform lockfile that records the exact dependency versions; do not edit it by hand. Swap cu130 for the index that matches your driver. For packages with compiled CUDA extensions such as flash-attn, the uv PyTorch guide points to prebuilt wheels on the Astral GPU indexes; pick the one that matches your Python, CUDA and PyTorch versions.
Step 7: Keep the uv cache with the environment, then copy your files off before you destroy
The uv cache docs say uv uses UV_CACHE_DIR (or --cache-dir) if set, otherwise $HOME/.cache/uv on Linux, and that if the cache sits on a different file system from the environment, uv cannot link files and must copy them instead. If you keep your work in another folder, point the cache there:
export UV_CACHE_DIR=~/work/.uv-cache
According to /terms, data on the instance is permanently deleted when you destroy it. Copy pyproject.toml, uv.lock and your code to your computer first (or keep them in a Git repository); on a new Raw GPU, uv sync in the project folder rebuilds the same environment. GPU time is billed per minute, rounded up, with a 1-minute minimum, and billing stops when you destroy the instance; see /terms.
Related guides
- How to install a specific PyTorch CUDA version on a cloud GPU
- How to set up a conda environment on a cloud GPU
FAQ
How do I install PyTorch with CUDA using uv?
Create an environment with uv venv --python 3.12, activate it, then run uv pip install torch torchvision --torch-backend=auto. According to the uv docs, auto queries the installed CUDA driver and picks the most compatible PyTorch index. You can also name a build, such as --torch-backend=cu130.
Why did uv install the CPU-only version of PyTorch?
The uv docs say --torch-backend=auto falls back to the CPU-only index if no GPU is found, and a plain install without a backend or index may not give you the build you expect. Check torch.version.cuda: if it prints None, reinstall with an explicit backend such as --torch-backend=cu130 or --index-url https://download.pytorch.org/whl/cu130.
Can I use --torch-backend with uv add or uv sync?
No. The uv docs say --torch-backend is only available in the uv pip interface. In a uv project, add the PyTorch index to pyproject.toml with explicit = true and point torch and torchvision to it under [tool.uv.sources], then run uv add or uv sync.
Which Python version should I use with uv and PyTorch?
The PyTorch Get Started page, read on 2026-10-29, says the latest stable PyTorch requires Python 3.11 or later. Ask uv for a version in that range, such as uv venv --python 3.12; uv downloads it for you if it is not installed.
How is a Raw GPU billed while I set up PyTorch with uv?
GPU time is billed per minute, rounded up, with a 1-minute minimum, and billing stops when you destroy the instance. See https://cloudgpu.app/terms for the full billing terms.
Sources
- uv docs, Using uv with PyTorch, read 2026-10-29
- uv docs, Installation, read 2026-10-29
- uv docs, Using Python environments, read 2026-10-29
- uv docs, Python versions, read 2026-10-29
- uv docs, Working on projects, read 2026-10-29
- uv docs, Caching, read 2026-10-29
- uv releases (0.13.6), read 2026-10-29
- PyTorch, Get Started, read 2026-10-29
- CloudGPU /pricing, /deploy, /terms, read 2026-10-29