1
votes

I am trying to use PyTorch with GPU in my Ubuntu 18.04. The GPU is a GeForce GTX 1070.

nvidia-smi:

| NVIDIA-SMI 460.67       Driver Version: 460.67       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 1070    Off  | 00000000:0B:00.0 Off |                  N/A |
| 21%   49C    P2    60W / 180W |   4598MiB /  8119MiB |     17%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
|   1  GeForce GTX 1070    Off  | 00000000:42:00.0 Off |                  N/A |
|  0%   48C    P8     7W / 180W |     20MiB /  8117MiB |      0%      Default |
|                               |                      |                  N/A |

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

.bashrc file:

export PATH="/usr/local/cuda-10.2/bin:$PATH"
export LD_LIBRARY_PATH="/usr/local/cuda-10.2/lib64:$LD_LIBRARY_PATH"

I installed pytorch using the command below (from here):

pip install torch torchvision torchaudio

Torch version:

PyTorch Version: 1.8.0

Python version:

Python 3.8.7

gcc/g++ versions:

gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
g++ (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0

If I try to get the GPU, I get the following:

>>> import torch
>>> print(torch.cuda.is_available())
False

Can anyone advice me please

1
What is your CUDA_HOME variable set to? See: discuss.pytorch.org/t/cuda-path-not-correctly-configured/63695/…jhso
Also, might be a naive suggestion but a reboot is always worth a try, see: discuss.pytorch.org/t/…jhso
And... finally, make sure that you have cuDNN downloaded and installed: docs.nvidia.com/deeplearning/cudnn/install-guide/index.htmljhso
Actually, there is no need to have CUDA/cuDNN in the host if you install via pip/conda. Both binaries have both libs inside. Are you sure this pip install is installing in the correct Python?Berriel
BTW, one thing that's always helpful is look at the actual syscalls. strace python -c 'import torch; print(torch.cuda.is_available())' will tell you what python is actually doing to ask the kernel to check in on the hardware; if there's something like a permission error trying to access a something in /dev or /sys it'll show up there.Charles Duffy

1 Answers

0
votes

If you look at pytorch page, they advise to use special command to install torch with cuda, so probably, you would like to use this one:

pip install torch==1.8.1+cu111 torchvision==0.9.1+cu111 torchaudio==0.8.1 -f https://download.pytorch.org/whl/torch_stable.html