GPU & CUDA · PyTorch / Python

PyTorch Installed Without CUDA

Error messageAssertionError: Torch not compiled with CUDA enabled

Why it happens

The active Python environment has a CPU-only PyTorch wheel installed (usually from plain pip install torch or an unpinned requirements file) instead of a CUDA-enabled build.

How to fix it

  1. Confirm the wheel variant with python -c "import torch; print(torch.__version__, torch.version.cuda)" (a +cpu suffix or None confirms CPU-only).
  2. Uninstall existing PyTorch packages: pip uninstall -y torch torchvision torchaudio (or conda remove pytorch torchvision torchaudio).
  3. Install PyTorch from the CUDA wheel index matching your driver's CUDA version from nvidia-smi (for example –index-url https://download.pytorch.org/whl/cu128).
  4. If installing from a project's requirements.txt, install the CUDA PyTorch wheel first so pip does not overwrite it with a PyPI CPU build.
pip uninstall -y torch torchvision torchaudio && pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu128

Seeing a different message? Paste it into the Error Code Fixer

Related errors

Fixes are reviewed by ComputerTech against current documentation, and software changes fast. If a step differs on your version, tell us. Back up important data before changing drivers, BIOS or system files.