Torch.cuda.is_available() gives False

nvcc -V gives me:
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2022 NVIDIA Corporation
Built on Wed_Sep_21_10:33:58_PDT_2022
Cuda compilation tools, release 11.8, V11.8.89
Build cuda_11.8.r11.8/compiler.31833905_0

I tried to install the most recent PyTorch version compatible with CUDA 11.8, but still, “torch.cuda.is_available()” gives False. What is the problem?

Your locally installed CUDA toolkit won’t be used unless you build PyTorch from source or a custom CUDA extension. You would need to properly install a current NVIDIA driver and PyTorch via the provided install instructions from here.

1 Like

I have had the same problem. The easiest way to work around it (for me), was install cuda toolkit with conda (I assume you are using a conda installation):

How to Install CUDA Toolkit and cuDNN with Conda (hatchjs.com)

Important advice: Create a virtual env to install all this DL packages …

conda activate <virtual_environment_name>

conda install -c conda-forge cudatoolkit=< CHECK YOUR VERSION > cudnn=< CHECK YOUR VERSION >