torch._C._cuda_getDeviceCount() > 0 returns False

How can I fix this? I have NVIDIA GPU.

>>> torch._C._cuda_getDeviceCount() > 0
False
>>> torch.cuda.is_available()
False
$ nvidia-smi
Fri Mar  5 17:28:31 2021       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 460.39       Driver Version: 460.39       CUDA Version: 11.2     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  GeForce GTX 165...  Off  | 00000000:01:00.0 Off |                  N/A |
| N/A   48C    P8     3W /  N/A |   1168MiB /  3911MiB |     17%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|    0   N/A  N/A      1163      G   /usr/lib/xorg/Xorg                133MiB |
|    0   N/A  N/A      2468      G   /usr/lib/xorg/Xorg                579MiB |
|    0   N/A  N/A      2688      G   /usr/bin/gnome-shell              166MiB |
|    0   N/A  N/A      3101      G   ...gAAAAAAAAA --shared-files      196MiB |
|    0   N/A  N/A    684945      G   /usr/lib/firefox/firefox            1MiB |
|    0   N/A  N/A    684970      G   /usr/lib/firefox/firefox            1MiB |
|    0   N/A  N/A    685042      G   /usr/lib/firefox/firefox            1MiB |
|    0   N/A  N/A    685193      G   /usr/lib/firefox/firefox            1MiB |
|    0   N/A  N/A    687287      G   /usr/lib/firefox/firefox            1MiB |
|    0   N/A  N/A    687389      G   /usr/lib/firefox/firefox            1MiB |
|    0   N/A  N/A    687497      G   /usr/lib/firefox/firefox            1MiB |
|    0   N/A  N/A   1693707      G   /opt/zoom/zoom                     50MiB |
|    0   N/A  N/A   1710209      G   /usr/lib/firefox/firefox            1MiB |
+-----------------------------------------------------------------------------+
$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2020 NVIDIA Corporation
Built on Mon_Nov_30_19:08:53_PST_2020
Cuda compilation tools, release 11.2, V11.2.67
Build cuda_11.2.r11.2/compiler.29373293_0

>>> torch.__version__
'1.8.0'


Python 3.8.5 (default, Jan 27 2021, 15:41:15) 
[GCC 9.3.0] on Linux


$ lsb_release -a
LSB Version:	core-11.1.0ubuntu2-noarch:security-11.1.0ubuntu2-noarch
Distributor ID:	Ubuntu
Description:	Ubuntu 20.04.2 LTS
Release:	20.04
Codename:	focal

on the download Website, I am noticing you don’t have anything for Cuda 11.2 so what should I do in this case?

This is most likely related to this and this post.
Make sure your driver is successfully installed without any errors, restart the machine, and it should work.
Also note, that you don’t need a local CUDA toolkit installation to execute the PyTorch binaries, as they ship with their own CUDA (cudnn, NCCL, etc.) runtimes.
The local CUDA toolkit is needed, if you want to build custom CUDA extensions or PyTorch from source.

If I have a new driver (version 530 with cuda 12 support) - does it supports Stable Torch for Cuda 11 (or below) ?

Yes, driver 530 supports the CUDA 11 and 12 runtimes.

I encountered the same issue while using an A800 GPU. My Nvidia driver version is 525.105.17, and I have CUDA 12.0 installed. I checked the cuda-toolkit-release-notes and found that CUDA 12.0.x requires driver version >=525.60.13.

I have installed torch-2.0.1-cp310-cp310-manylinux1_x86_64 . However, when I executed the following code, I encountered an exception:

python -c “import torch; print(torch.cuda.is_available())”

torch/cuda/init.py:107: UserWarning: CUDA initialization: Unexpected error from cudaGetDeviceCount(). Did you run some cuda functions before calling NumCudaDevices() that might have already set an error? Error 802: system not yet initialized (Triggered internally at …/c10/cuda/CUDAFunctions.cpp:109.)
return torch._C._cuda_getDeviceCount() > 0
False

Is there a version of PyTorch available that supports the A800 GPU and CUDA 12?

Yes, all of our PyTorch binaries support this GPU and also your error points towards a driver issue.

How can we fix this problems? If NVidia cannot fix there broken video driver, may be have another way to fix this bug?

I doubt the video driver is broken and the aforementioned issues are often caused by e.g. a not performed restart, while it was requested, multiple conflicting installations, etc.