Cannot get Pytorch to run with CUDA - Windows 11 and RTX3060 (nvidia driver 551.23)

I am trying to install PyTorch with Cuda using Anaconda3, on Windows 11:

  • My GPU is RTX 3060.
  • My conda environment is Python 3.10.13.
  • nvidia-smi outputs Driver Version: 551.23, CUDA Version: 12.4.

I used the following command to install PyTorch:

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

No matter what I try, torch.cuda.is_available() is always False.

I had CUDA installed separately but I’ve uninstalled it since many posts online suggest that PyTorch already comes with CUDA.

Cross-posted on python - Cannot convince Pytorch to install with Cuda (Windows 11) - Stack Overflow (couldn’t post on discuss.pytorch.org - apparently email verifications don’t work)

SOLVED: I had a global non-CUDA PyTorch installation that was interfering with the virtual environment. The key trick (suggested on StackOverflow) was to run torch.cuda.get_arch_list() - it returned an empty list, indicating the wrong torch was being picked up, in spite of being inside of the Anaconda environment!

Hi,

I am facing a very similar issue, nvidia-smi outputs conda12.4, and I also ran torch.cuda.get_arch_list and got empty list. I would be very grateful if you can please help me debug this. Thank you

You need to make sure torch is coming from your Anaconda installation. It probably isn’t, such as was in my case. You can try troubleshooting further by finding out where Python is getting torch from:

import torch
print(torch. __ path __ )

If you’re getting something like [‘C:\Python310\lib\site-packages\torch’] then this is your problem - pip uninstall it and try again.

P.S. There should be no spaces next to the underscores but the editor decided to convert underscores to bold :(

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.