John C.
John C.

Reputation: 445

CUDA 11.3 not being detected by PyTorch [Anaconda]

I am running Ubuntu 20.04 on GTX 1050TI. I have installed CUDA 11.3.

nvidia-smi output:

Wed Apr  6 18:27:23 2022       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 465.19.01    Driver Version: 465.19.01    CUDA Version: 11.3     |
|-------------------------------+----------------------+----------------------+
| 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  NVIDIA GeForce ...  Off  | 00000000:01:00.0 Off |                  N/A |
| N/A   44C    P8    N/A /  N/A |     11MiB /  4040MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|    0   N/A  N/A      3060      G   /usr/lib/xorg/Xorg                  4MiB |
|    0   N/A  N/A      4270      G   /usr/lib/xorg/Xorg                  4MiB |
+-----------------------------------------------------------------------------+

nvcc --version output:

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Sun_Mar_21_19:15:46_PDT_2021
Cuda compilation tools, release 11.3, V11.3.58
Build cuda_11.3.r11.3/compiler.29745058_0

Anaconda PyTorch isn't detecting CUDA:

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

Any ideas how to solve the issue?

Upvotes: 0

Views: 4745

Answers (1)

John C.
John C.

Reputation: 445

The solution:

Conda in my case installed cpu build. You can easily identify your build type by running torch.version.cuda which should return a string in case you have the CUDA build. if you get None then you are running the cpu build and it will not detect CUDA

To fix that I installed torch using pip instead :

pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu113

Upvotes: 1

Related Questions