Torch not getting GPU

Hello, Im trying to use pytorch with GPU in my ubuntu 18.04. The GPU is a GeForce GTX 1070

nvidia-smi:

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:

pip install torch torchvision torchaudio

from here

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

Did the logs show that the CUDA runtime was also installed?
If so, what does torch.version.cuda return?
Note that the binaries ship with their own CUDA runtime (as well as cudnn, NCCL etc.), so your local CUDA toolkit won’t be used unless you build PyTorch from source or any custom CUDA extension.

1 Like

I would say use anaconda enovirement and install torch using conda .
Look out for command like
conda install pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch

you can see the command in https://pytorch.org/

conda command will install all CUDA libraries required.

Now if you still don’t want to use anaconda then you have to check for PyTorch version compatibility with installed system CUDA.
I can see your command is compatible with CUDA 10.2
but you have CUDA 11.2 installed.
i don’t know compatible PyTorch version of CUDA 11.2

I would suggest use anaconda, it will save lot of time.

1 Like

Hey, thanks for your reply. Using conda solved my problems!!

Thanks for your reply. Problem solved