My pytorch-cuda version is 11.6 in my conda environment and I have installed CUDA 11.3

Dear All,

I have been struggling to get run my PyTorch on GPU. I am new to this hence might be doing something wrong:

C:\Users\axs0959>nvidia-smi
Sun Jan 15 23:19:21 2023
±----------------------------------------------------------------------------+
| NVIDIA-SMI 465.89 Driver Version: 465.89 CUDA Version: 11.3 |
|-------------------------------±---------------------±---------------------+
| GPU Name TCC/WDDM | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 NVIDIA GeForce … WDDM | 00000000:01:00.0 On | N/A |
| 33% 57C P0 79W / 250W | 870MiB / 11264MiB | 0% Default |
| | | N/A |
±------------------------------±---------------------±---------------------+

(ailab) C:\Users\axs0959>nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2022 NVIDIA Corporation
Built on Tue_Mar__8_18:36:24_Pacific_Standard_Time_2022
Cuda compilation tools, release 11.6, V11.6.124
Build cuda_11.6.r11.6/compiler.31057947_0

import torch
print(torch.version.cuda)
None
print(torch.cuda.is_available())
False
print(torch.cuda.device_count())
0

I have installed the CUDA and cudnn on Windows 10. I have set the environment variables, restarted my computer and I know that I am missing something.

Thanks,
Aileen

This indicates that you’ve installed the CPU-only PyTorch binary without a CUDA runtime.
Use the install commands from here and make sure the install log shows that the right binary is selected.

Hello,

I actually did try it a couple of times and due to some unknown reason after selecting this query:

conda install pytorch torchvision torchaudio pytorch-cuda=11.6 -c pytorch -c nvidia

I get this:

Package Plan

environment location: C:\Users\axs0959\Anaconda3\envs\ailab

added / updated specs:
- pytorch
- pytorch-cuda=11.6
- torchaudio
- torchvision

The following packages will be UPDATED:

pytorch 1.12.1-py3.10_cpu_0 → 1.13.1-py3.10_cpu_0
torchaudio 0.12.1-py310_cpu → 0.13.1-py310_cpu
torchvision 0.13.1-py310_cpu → 0.14.1-py310_cpu

Do you recommend I uninstall PyTorch completely for this environment and start fresh?

Hello,

Although the popular belief was that once the torch in uninstalled, it does create problems during installation, I went ahead and installed it.

Here is the outcome:

print(torch.version.cuda)
11.6
print(torch.cuda.is_available())
True
print(torch.cuda.device_count())
1
print(torch.cuda.device_name)
Traceback (most recent call last):
File “”, line 1, in
AttributeError: module ‘torch.cuda’ has no attribute ‘device_name’. Did you mean: ‘get_device_name’?
print(torch.cuda.get_device_name())
NVIDIA GeForce GTX 1080 Ti

The lesson learned here is that if this issue occurs then use:

conda uninstall pytorch

to uninstall the pytorch version from the environment otherwise, if you try to reinstall with the new command, in case you have accidentally installed the CPU version, the environment will just get updated with the latest version of the same pytorch 1.12.1-py3.10_cpu_0 or whichever version you have and you would still have the pytorch CPU version.

Thanks for the advice.
Aileen