RuntimeError: No CUDA GPUs are available
I want to train a gpt2 model in my laptop and I have a GPU in it and my os is windows , but I always got this error in python:
torch._C._cuda_init()
RuntimeError: No CUDA GPUs are available

when I tried to check the availability of GPU in the python console, I got true:
import torch
torch.cuda.is_available()
Out[4]: True

but I can't get the version by
nvcc version 
#or  nvcc --version
NameError: name 'nvcc' is not defined

I use this command to install CUDA
conda install pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch  

What can I do to make the GPU available for python?

In my case the problem was that the CUDA drivers that I was trying to install, didn't support my GPU model. In your case, please check which CUDA driver supports your GPU model. You are now installing 10.2. In my case CUDA 11.0 and 11.2 supported my GPU model but not 11.3 which I was trying to install.
If you got the same error after a while, which can happen if you run a cloud vm which hardware can be updated automatically, here is how to solve it:
Remove CUDA drivers
sudo apt-get remove --purge nvidia*

Then reinstall the drivers as follows. Note! in this case I have debian distro on x64 system.
wget https://developer.download.nvidia.com/compute/cuda/repos/debian11/x86_64/cuda-keyring_1.0-1_all.deb
sudo dpkg -i cuda-keyring_1.0-1_all.deb
sudo add-apt-repository contrib
sudo apt-get update
sudo apt-get -y install cuda 

Get the correct commands that works for your distro and system from the link: https://developer.nvidia.com/cuda-downloads?target_os=Linux
Good luck!
