Torch.cuda.is_available() returns False with CUDA 10.2 Python3.8 Pytorch1.5 and1.6 ubuntu 16.04

I try to install pytorch on my server but it cannot find GPU. torch.cuda.is_available() always returns False. I have checked all that I can check(driver version, GPU compatibility, GCC version, kernel version).It still does not work.

First, I install pytorch by pip install torch torchvision. collect_env.py result:

pip 10.2 1.6

Collecting environment information...
PyTorch version: 1.6.0
Is debug build: No
CUDA used to build PyTorch: 10.2

OS: Ubuntu 16.04.4 LTS
GCC version: (Ubuntu 5.4.0-6ubuntu1~16.04.11) 5.4.0 20160609
CMake version: version 3.5.1

Python version: 3.8
Is CUDA available: No
CUDA runtime version: 10.2.89
GPU models and configuration:
GPU 0: Tesla P40
GPU 1: Tesla P40
GPU 2: Tesla P40
GPU 3: Tesla K80
GPU 4: Tesla K80

Nvidia driver version: 440.33.01
cuDNN version: Could not collect

Versions of relevant libraries:
[pip3] numpy==1.19.1
[pip3] torch==1.6.0
[pip3] torchvision==0.7.0
[conda] numpy                     1.19.1                   pypi_0    pypi
[conda] torch                     1.6.0                    pypi_0    pypi
[conda] torchvision               0.7.0                    pypi_0    pypi

I uninstall pytorch and reinstall it by conda install pytorch torchvision cudatoolkit=10.2 -c pytorch,collect_env.py result:

Collecting environment information...
PyTorch version: 1.6.0
Is debug build: No
CUDA used to build PyTorch: 10.2

OS: Ubuntu 16.04.4 LTS
GCC version: (Ubuntu 5.4.0-6ubuntu1~16.04.11) 5.4.0 20160609
CMake version: version 3.5.1

Python version: 3.8
Is CUDA available: No
CUDA runtime version: 10.2.89
GPU models and configuration:
GPU 0: Tesla P40
GPU 1: Tesla P40
GPU 2: Tesla P40
GPU 3: Tesla K80
GPU 4: Tesla K80

Nvidia driver version: 440.33.01
cuDNN version: Could not collect

Versions of relevant libraries:
[pip3] numpy==1.19.1
[pip3] torch==1.6.0
[pip3] torchvision==0.7.0
[conda] blas                      1.0                         mkl    defaults
[conda] cudatoolkit               10.2.89              hfd86e86_1    defaults
[conda] mkl                       2020.1                      217    defaults
[conda] mkl-service               2.3.0            py38he904b0f_0    defaults
[conda] mkl_fft                   1.1.0            py38h23d657b_0    defaults
[conda] mkl_random                1.1.1            py38h0573a6f_0    defaults
[conda] numpy                     1.19.1           py38hbc911f0_0    defaults
[conda] numpy-base                1.19.1           py38hfa32c7d_0    defaults
[conda] pytorch                   1.6.0           py3.8_cuda10.2.89_cudnn7.6.5_0    pytorch
[conda] torchvision               0.7.0                py38_cu102    pytorch

torch.cuda.is_available() always returns False… I need your help.

results of nvcc --version

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Wed_Oct_23_19:24:38_PDT_2019
Cuda compilation tools, release 10.2, V10.2.89

I think There is no cuda installed.

Is CUDA available: No

You might have to download cuda (10.2) from nvidia.

Hi.

I installed CUDA on my machine but I am using an anaconda environment to work with PyTorch. So in the environment, when I install PyTorch, cudatoolkit is also installed. But when I run it in python, it’s not recognizing the GPU. What should I do then?

NVIDIA driver: 450.57
Python: 3.8
pytorch: 1.5
torchvision: 0.6
cudatoolkit: 10.1.243

What should I do?

I have installed cuda. results of nvcc --version:

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Wed_Oct_23_19:24:38_PDT_2019
Cuda compilation tools, release 10.2, V10.2.89

as

pytorch: 1.5
torchvision: 0.6
cudatoolkit: 10.1.243

You have installed 10.1 version which may be not compatible with 10.2 release . ,

# CUDA 9.2
conda install pytorch==1.5.0 torchvision==0.6.0 cudatoolkit=9.2 -c pytorch

# CUDA 10.1
conda install pytorch==1.5.0 torchvision==0.6.0 cudatoolkit=10.1 -c pytorch

# CUDA 10.2
conda install pytorch==1.5.0 torchvision==0.6.0 cudatoolkit=10.2 -c pytorch

# CPU Only
conda install pytorch==1.5.0 torchvision==0.6.0 cpuonly -c pytorch

source : https://pytorch.org/get-started/previous-versions/

While installing be sure remove previous pytorch and cudatoolkits and make new conda enviroment to avoid conflicts.

I think you should remove and reinstall pytorch in new conda enviroment. Also restarting might work sometimes.

1 Like

my collect_env.py results are pretty much the same as yours.

$ python collect_env.py 
Collecting environment information...
PyTorch version: 1.6.0
Is debug build: No
CUDA used to build PyTorch: 10.2

OS: Ubuntu 18.04.3 LTS
GCC version: (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
CMake version: version 3.10.2

Python version: 3.7
Is CUDA available: Yes
CUDA runtime version: 10.2.89
GPU models and configuration: GPU 0: GeForce RTX 2060
Nvidia driver version: 440.33.01
cuDNN version: /usr/lib/x86_64-linux-gnu/libcudnn.so.7.6.4

Versions of relevant libraries:
[pip3] numpy==1.16.2
[conda] blas                      1.0                         mkl  
[conda] cudatoolkit               10.2.89              hfd86e86_1  
[conda] efficientnet-pytorch      0.6.3                    pypi_0    pypi
[conda] mkl                       2019.4                      243  
[conda] mkl-service               2.3.0            py37he904b0f_0  
[conda] mkl_fft                   1.0.15           py37ha843d7b_0  
[conda] mkl_random                1.1.0            py37hd6b4f25_0  
[conda] numpy                     1.17.4           py37hc1035e2_0  
[conda] numpy-base                1.17.4           py37hde5b4d6_0  
[conda] numpydoc                  0.9.2                      py_0  
[conda] pytorch                   1.6.0           py3.7_cuda10.2.89_cudnn7.6.5_0    pytorch
[conda] torchvision               0.7.0                py37_cu102    pytorch

But as you can see I do not have this

You should maybe try and properly uninstall the pytorch you installed via pip3

Yup. Rebooting helped!!! Thanks

1 Like