AssertionError:Torch not compiled with CUDA enabled

I got this error after updating torch and torchvision :- Torch not compiled with CUDA enabled.
Before this I was able to train model on GPU.
Current version of torch(after updating) is 1.9.0+cpu.
After searching on internet I updated my Cuda 11.0 to 11.3 and GTX1050ti driver version 451.82 to 466.77.
It’s not working still, what should I do now?

Where are you installing your version of torch from? It could be that the binary package was not compiled with CUDA support.

It indeed seems to be the case:

@Bhavya_Soni make sure you are specifying the desired CUDA runtime version when installing the binaries as given here.

I was getting some package not found error so I tried to do pip install --upgrade torch torchvision.
After that I got this error.

Looks like PyTorch doesn’t support CUDA 11.3 right now. It’s showing for CUDA 11.1 + torch 1.9.0
So do I need to downgrade the CUDA version? @ptrblck

Not necessarily. The binaries ship with their CUDA runtime (as well as cudnn, NCCL etc.) so your local CUDA toolkit installation won’t be used unless you are building PyTorch from source or are compiling a custom CUDA extension.

So how can I do that ? I mean “CUDA toolkit installation won’t be used unless you are building PyTorch from source or are compiling a custom CUDA extension” how can I do this?

You can just install the NVIDIA driver, select a desired PyTorch binary using the posted link, and install it.
E.g.

conda install pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch

will install PyTorch with the CUDA 10.2 runtime (as well as cudnn7.6.5).

pip install torch==1.9.0+cu102 torchvision==0.10.0+cu102 torchaudio===0.9.0 -f https://download.pytorch.org/whl/torch_stable.html

This was helpful , Thank you.