1

I have torch installed in a conda environment. When I run python in command line and try to check CUDA availability I get False as show below.

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

However, when I use jupyter notebook, it shows CUDA is available. I'm using the same environment. The GPU is on the same local Windows machine

import torch
torch.cuda.is_available()
> True
!which python
> /c/Users/b2bt/anaconda3/envs/stable-diffusion/python

I tried creating a new conda environment to run the stable diffusion web UI. I've installed torch previously in a different environment and have used it successfully with GPU. I was expecting the terminal to show CUDA available but strangely it doesn't.

kamal tanwar
  • 197
  • 8

2 Answers2

2

This problem may be caused by using pip install pytorch to install package.

Solution:

Open the official website, and search for the correct version for your environment.

enter image description here

pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu117
MingJie-MSFT
  • 5,569
  • 1
  • 2
  • 13
  • I never got to try this solution but thanks for answering. Previously I was using the .bat file to install everything which was provided in the repository. But then I tried installing everything manually and it worked. – kamal tanwar Jun 14 '23 at 18:54
  • Thanks! I used `pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu117` and it worked for me. – Sughosh Kulkarni Aug 08 '23 at 14:03
2

I had the same issue as you have. I realized pytorch was not installed.

So, installed in using pip3 command stated above:

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