§09.18

Fix pip install torch (CPU-only or CUDA mismatch)

Plain pip install torch gives a CPU-only build on Windows. Install from the PyTorch index URL that matches your CUDA, then verify the GPU.

by published 21 Oct 2026 checked against docs 21 Oct 2026 3 min in Local LLMs Markdown

On this page5 sections
  1. 1. Check what you actually have
  2. 2. Remove the CPU-only build
  3. 3. Install the build that matches your CUDA
  4. 4. Match the driver to the toolkit
  5. 5. Verify the GPU build

By default pip install torch pulls a CPU-only build on Windows, and on Linux it may not match your installed CUDA, so torch.cuda.is_available() returns False. The fix is to install from the PyTorch index URL that matches your CUDA version.

1. Check what you actually have

import torch
print(torch.__version__, torch.version.cuda, torch.cuda.is_available())

A version ending in +cpu, a None CUDA, or False means you have the CPU-only build.

2. Remove the CPU-only build

pip uninstall -y torch torchvision torchaudio

Uninstall first so pip does not keep the cached CPU wheel; the command is the same on every OS.

3. Install the build that matches your CUDA

Open the official selector, pick your OS and CUDA version, and copy the command it shows. It uses an --index-url like this:

pip install torch --index-url https://download.pytorch.org/whl/cu<version>

Replace cu<version> with the value from the selector, for example cu126 or cu130 today; do not guess it. On macOS there is no CUDA build, so the default pip install torch using Metal is correct.

4. Match the driver to the toolkit

The pip wheel bundles its own CUDA runtime, so you do not need the full CUDA Toolkit, only an NVIDIA driver new enough for that runtime.

nvidia-smi

The top-right CUDA version is the maximum your driver supports; pick a wheel at or below it.

5. Verify the GPU build

import torch
print(torch.cuda.is_available(), torch.cuda.get_device_name(0))

True plus your GPU name means torch can use CUDA. See how much RAM or VRAM a model needs, then run a model with the Transformers pipeline quickstart.

If it fails:

  • Still False after reinstall: a second torch is shadowing it; run pip uninstall torch until none remain, then reinstall once.
  • AssertionError: Torch not compiled with CUDA enabled: you reinstalled the CPU wheel; re-run with the --index-url for your CUDA.
  • DLL load failed on Windows: the driver is older than the wheel’s CUDA runtime; update the NVIDIA driver. Full matrix on the PyTorch install page.

← All Local LLMs plates · Search all guides

↑↓ move↵ openalt+↵ copy first command

Keyboard

⌘/ctrl+K or /
Search all guides
alt+↵
In search: copy the guide's first command
j / k
Move through a list of guides
c
On a guide: copy its first command
t
Toggle light / dark
?
This list