0

I am trying to execute code with pytorch in visual studio code, the problem is that I must be able to do it from the CPU. But my idea is that for certain deep learning projects to use the gpu and others not. How can I switch from CPU to GPU when i run

import torch
torch.cuda.is_available()

the output is "False".

i have cuda already installed. I'm using Ubuntu 20.04.2 . It is important for me to do it in Visual Studio Code

emanuel lemos
  • 59
  • 2
  • 7
  • Similar question: https://stackoverflow.com/questions/60987997/why-torch-cuda-is-available-returns-false-even-after-installing-pytorch-with. In short, your GPU might not support the required compute capability – ForceBru Mar 09 '21 at 18:13
  • make sure you have the correct interpreter in VSC. – Quang Hoang Mar 09 '21 at 18:55

1 Answers1

0

Several issues could prevent you from using a GPU.

  1. The GPU is not supported by CUDA or does not have the minimum CUDA version
  2. You installed PyTorch CPU instead of the GPU variant. You will need to reinstall from the PyTorch website
imLightSpeed
  • 147
  • 1
  • 9