0

I try to find out why the GPU is recognized with :

import tensorflow as tf
tf.test.is_gpu_available() #I'm getting TRUE as output

and not with:

import torch
torch.cuda.is_available() #I'm getting False as output

my 'pip list' output command concerning Pytorch is :

torch                         2.0.1
torchaudio                    2.0.2
torchvision                   0.15.2

How can I fix Pytorch so as it can detect the GPU ?

Thank you

jeanluc
  • 67
  • 6

1 Answers1

1

A Mac with an M2 doesn't have a CUDA-capable GPU. However, you can use MPS acceleration:

torch.backends.mps.is_available() # True
device = torch.device("mps")
x = torch.tensor([1,2,3], device=device) # This will use MPS acceleration.
  • Thank you for your response. I understand better now. For my general knowledge, can we say that MPS acceleration provided by Apple is equivalent to NVIDIA GPus ? – jeanluc Jul 25 '23 at 09:50
  • It's similar, but some tensor operations (PyTorch functions) aren't supported yet, and it will be much slower than a high-end CUDA-capable GPU. – DefinitelyNotAPlesiosaur Jul 25 '23 at 18:00