“AssertionError: Torch not compiled with CUDA enabled” in spite upgrading to CUDA version

you dont have to install it via anaconda, you could install cuda from their website. after install ends open a new terminal and check your cuda version with:

>>> nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Thu_Nov_18_09:52:33_Pacific_Standard_Time_2021
Cuda compilation tools, release 11.5, V11.5.119
Build cuda_11.5.r11.5/compiler.30672275_0

my is V11.5

then go here and select your os and preferred package manager(pip or anaconda), and the cuda version you installed, and copy the generated install command, I got:

pip3 install torch==1.10.1+cu113 torchvision==0.11.2+cu113 torchaudio===0.10.1+cu113 -f https://download.pytorch.org/whl/cu113/torch_stable.html

notice that for me I had python 3.10 installed but my project run over 3.9 so either use virtual environment or run pip of your wanted base interpreter explicitly (for example C:\Software\Python\Python39\python.exe -m pip install .....)
else you will be stuck with Could not find a version that satisfies the requirement torch errors

then open python console and check for cuda availability

>>> import torch
>>> torch.cuda.is_available()
True

Leave a Comment