GPU & CUDA · PyTorch / Python
PyTorch Installed Without CUDA
Error message
AssertionError: Torch not compiled with CUDA enabledWhy 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
- Confirm the wheel variant with python -c "import torch; print(torch.__version__, torch.version.cuda)" (a +cpu suffix or None confirms CPU-only).
- Uninstall existing PyTorch packages: pip uninstall -y torch torchvision torchaudio (or conda remove pytorch torchvision torchaudio).
- 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).
- 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/cu128Seeing a different message? Paste it into the Error Code Fixer
Related errors
- PyTorch CUDA Out of Memory
- PyTorch Cannot Detect CUDA GPU
- Connection refused on port 11434
- Model requires more system memory
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.