# 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.

- Canonical: https://guides-ai.com/guides/fix-pip-install-torch-cuda/
- Plate 09.18 · Topic: Local LLMs (https://guides-ai.com/topics/local-llm/)
- Published: 21 Oct 2026 · 3 min read
- Source site: guides-ai — https://guides-ai.com/

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

```python
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

```bash
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:

```bash
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.

```bash
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

```python
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](/guides/local-llm-ram-vram-requirements/), then run a model with the [Transformers pipeline quickstart](/guides/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](https://pytorch.org/get-started/locally/).
