torch.cuda.device_count() return 0
Asked Answered
L

1

13

I have installed pytorch under virtualenv via:

pip3 install https://download.pytorch.org/whl/cu100/torch-1.0.1.post2-cp35-cp35m-linux_x86_64.whl
pip3 install torchvision

But for some reason:

import torch
torch.cuda.device_count()
0
torch.cuda.is_available()
False

Looks like pytorch detected cuda 9 for some reason:

torch._C._cuda_getDriverVersion()
9010

My system:

lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.5 LTS
Release:    16.04
Codename:   xenial


nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Fri_Feb__8_19:08:17_PST_2019
Cuda compilation tools, release 10.1, V10.1.105


Python 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609] on linux


ls -l /usr/local/ | grep cuda
lrwxrwxrwx  1 root   root      21 Mar 24 02:05 cuda -> /usr/local/cuda-10.0/
drwxr-xr-x 17 root   root    4096 Mar 24 02:06 cuda-10.0
drwxr-xr-x 15 root   root    4096 Nov 29 23:03 cuda-9.0
drwxr-xr-x 15 root   root    4096 Jan 10  2018 cuda-9.1

nvidia-smi -q | grep "Product Name"
    Product Name                    : GeForce GTX TITAN X
    Product Name                    : GeForce GTX 1080 Ti
Leveloff answered 24/3, 2019 at 12:45 Comment(1)
See Why `torch.cuda.is_available()` returns False even after installing pytorch with cuda?. This particular error appears to be the result of an out-of-date driver. torch._C._cuda_getDriverVersion() indicates that the latest version of CUDA the driver supports is CUDA 9.1.Choragus
B
1

If torch._C._cuda_getDriverVersion() gives driver values, please try torch._C._cuda_getDeviceCount() to understand more.

Borehole answered 30/6, 2022 at 7:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.