PyTorch with CUDA support is not installed, although everything worked before that

Everything worked fine for about 2 years. Unexpectedly, I discovered an error connecting to CUDA today.

Now the torch.cuda.is_available() function is False, and the torch.zeros(1).cuda() command returns the error: Torch is not compiled with CUDA enabled. It’s very similar to the fact that I have a version of torch installed without CUDA, but I didn’t change anything and just a couple of days ago I was quietly using CUDA.

If you type “nvidia-smi” into the console:
NVIDIA-SMI 576.02 Driver Version: 576.02 CUDA Version: 12.9

I deleted torch to reinstall it, but an error occurs when trying to install it:
pip3 install torch torchvision --index-url https://download.pytorch.org/whl/сu129

WARNING: Ignoring invalid distribution -illow
WARNING: Ignoring invalid distribution -pencv-python
ERROR: Could not find a version that satisfies the requirement torch (from versions: none)
ERROR: No matching distribution found for torch

I tried other variations of the installation commands, but nothing works, the errors are similar:
pip3 install torch==2.8.0 torchvision==0.23.0 torchaudio==2.8.0 --index-url https://download.pytorch.org/whl/cu128

and other versions of cu121, cu126, cu130

pip install torch==2.9.0+cu128 --index-url https://download.pytorch.org/whl/cu128
Looking in indexes: https://download.pytorch.org/whl/cu128
ERROR: Could not find a version that satisfies the requirement torch==2.9.0+cu128 (from versions: none)
ERROR: No matching distribution found for torch==2.9.0+cu128

I have Python 3.10.2 (64bit)

How do I install pytorch with CUDA? Why did everything work on CUDA a couple of days ago, but now it doesn’t? In the Task Manager, I made sure that CUDA is present, but something prevents me from installing and connecting the library to it.

Please refer to our install instructions. E.g. a simple pip install torch will install the latest stable PyTorch release (2.9.0) with CUDA support (12.8) on Linux x86.

Unfortunately, we would not know what exactly happened to your setup. Based on your description I guess a new virtual environment was created and the CPU-only PyTorch binary was installed. The other installation errors are often raised e.g. if an unsupported Python version is used (e.g. an old version or the 32 bit version).

1 Like