Torch.cuda.is_available() returns False, nvidia-smi is working

Just created a new deep learning server and am running into an issue running PyTorch code using CUDA. nvidia-smi gives seemingly correct output (below):

| NVIDIA-SMI 384.145                Driver Version: 384.145                   |
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|   0  TITAN Xp            Off  | 00000000:01:00.0 Off |                  N/A |
|  0%   38C    P0    58W / 250W |      0MiB / 12187MiB |      2%      Default |
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|  No running processes found                                                 |

However, when I run torch.cuda.is_available(), I get the following output:

Python 3.6.6 |Anaconda, Inc.| (default, Jun 28 2018, 17:14:51) 
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> torch.cuda.is_available()

Any ideas as to what’s wrong? System information is below.

  • OS: Ubuntu 16.04

  • PyTorch Version: 0.4

  • PyTorch Installation Method: Conda

  • Python Version: 3.6.6

  • CUDA/cuDNN Version: 9.2/7.1

  • GPU Model: 1 NVIDIA Titan XP

1 Like

The problem is most likely that your display driver version 384.145 is too old compare to
cuda 9.2 you are using. Update the display driver to version 396.xx (cuda 9.2 comes with
396.26) may help solve the problem (that torch.cuda.is_available() is False).


@Chun_Li Thanks, downgraded to CUDA 9.1 and upgraded display driver to 3.96 and all works now.

Why downgraded to CUDA 9.1? As long as you updated the display driver to 396.xx,
CUDA 9.2 should work and better than CUDA 9.1 (especially on the compatibility with gcc 7.x.x).

I assumed that I had to build PyTorch from source for CUDA 9.2 compatibility and ran into issues during the build process. I downgraded to 9.1 so that I could just use Anaconda to install the CUDA 9.1 compatible binary.

I see. Yes, if you just use Anaconda to install the CUDA 9.1 compatible binary, then use CUDA 9.1.
If you want to compile pytorch from source, using CUDA 9.2 is a better choice.

I got the same problem after suspending my ubuntu 16.04. I restart it then the “torch.cuda.is_available()” return “True”. Hahaha

I am getting the same problem now, after upgrading to pytorch 1, CUDA 92.
(Was working fine with earlier versions of pytorch and CUDA)

torch.cuda.is_available() is FALSE
but torch.backends.cudnn.enabled is TRUE.
Nvidia-smi working fine, reports:
NVIDIA-SMI 396.37 Driver Version: 396.37

Any suggestions?

1 Like

I get the same problem, too
“torch.cuda.is_available() is FALSE
but torch.backends.cudnn.enabled is TRUE”
Driver Version is 396.82
Have you solved this problem?

Which CUDA version are you using?
Based on the driver, you could only use CUDA<=9.2 as shown here.
I would recommend to update the driver and the CUDA version (if you are using an older one).

1 Like

Thank you
The CUDA version is 9.0
But according to this link, driver version 396.82 seems to be OK
Additionally, when print(torch.version.cuda), the result is 9.0.176

Could you check, if nvidia-smi and nvidia-settings is working on your system and show all installed GPUs?
If so, could you create a new environment and try to install a PyTorch again?

Thank you for your assistance!
We have solved the problem.
There are two nvidia drivers.
So we delete one and reinstall pytorch, and then torch.cuda.is_available() becomes true.
Hope it’s helpful to others.

Sorry for reopening but I have the same problem. I am on Windows 10, nvidia-smi gives 417.98 and the driver version is the same, while CUDA version is 10.0 and cudnn is 7.0. It used to work properly till recently, so I suppose that something should be updated. My questions are:

  1. What to update to make it work?
  2. How to do it in a safest possible way?
  3. How to proceed in future so that things get updated accordingly to latest demands?

Hi every one,
Torch.cuda.is_available() is returning False.
It used to work well until recently. I have tried to reboot the machine multiple times
I don’t remember changing the drivers in the PC anytime in between. I am on Windows 10 64 bit

C:\Program Files\NVIDIA Corporation\NVSMI>nvidia-smi
Sat Jul 04 11:23:40 2020
| NVIDIA-SMI 432.00       Driver Version: 432.00       CUDA Version: 10.1     |
| GPU  Name            TCC/WDDM | Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|   0  GeForce RTX 2080   WDDM  | 00000000:01:00.0  On |                  N/A |
| 24%   28C    P8    19W / 215W |    542MiB /  8192MiB |      0%      Default |

| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|    0      1312    C+G   Insufficient Permissions                   N/A      |
|    0      2316    C+G   ...r\Anaconda3\envs\tensorflow\pythonw.exe N/A      |
|    0      3904    C+G   ...Screen Control\bin\OnScreen Control.exe N/A      |
|    0      4248    C+G   ...AppData\Local\slack\app-4.6.0\slack.exe N/A      |
|    0      4388    C+G   ...)\Microsoft\Edge\Application\msedge.exe N/A      |
|    0      5312    C+G   C:\Windows\explorer.exe                    N/A      |
|    0      5632    C+G   ...1.0_x64__8wekyb3d8bbwe\WinStore.App.exe N/A      |
|    0      7024    C+G   ...dows.Cortana_cw5n1h2txyewy\SearchUI.exe N/A      |
|    0      8136    C+G   ...osoft.LockApp_cw5n1h2txyewy\LockApp.exe N/A      |
|    0      8412    C+G   ...DIA GeForce Experience\NVIDIA Share.exe N/A      |
|    0      9884    C+G   ....110.0_x64__8wekyb3d8bbwe\YourPhone.exe N/A      |
|    0     10544    C+G   ...hell.Experiences.TextInput.InputApp.exe N/A      |
|    0     11004    C+G   ...0.0.0_x64__8wekyb3d8bbwe\Calculator.exe N/A      |
|    0     11184    C+G   ...mmersiveControlPanel\SystemSettings.exe N/A      |

C:\Program Files\NVIDIA Corporation\NVSMI>nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2018 NVIDIA Corporation
Built on Sat_Aug_25_21:08:04_Central_Daylight_Time_2018
Cuda compilation tools, release 10.0, V10.0.130

Did you update PyTorch or could it have been updated/downgraded accidentally by another package?
I would recommend to create a new virtual environment and reinstall the latest PyTorch + CUDA package to check, if your current Python environment might have been broken somehow.

@ptrblck Thanks for dropping by . Its working in my dual booted Ubuntu in the same machine. As you mentioned it should work in a new virtual env. Yet to check that … Thank You.

Hi, may I ask how to upgrade the display driver? And why the display driver will hurts the pytorch?

/home/kash/pytorch/lib/python3.8/site-packages/torch/cuda/ UserWarning: CUDA initialization: CUDA unknown error - this may be due to an incorrectly set up environment, e.g. changing env variable CUDA_VISIBLE_DEVICES after program start. Setting the available devices to be zero. (Triggered internally at /pytorch/c10/cuda/CUDAFunctions.cpp:100.)
return torch._C._cuda_getDeviceCount() > 0

why is this error showing…i dont know im beginner
CUDA Version: 11.0
Driver Version: 450.80.02

Your system might be in a bad state, e.g. after a driver update without a restart.
Reboot the machine and retry importing PyTorch.