How to run Pytorch on Macbook pro (M1) GPU?
I tried to train a model using PyTorch on my Macbook pro. It uses the new generation apple M1 CPU. However, PyTorch couldn't recognize my GPUs.
GPU available: False, used: False
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs

Does anyone know any solution?
I have updated all the libraries to the latest versions.

PyTorch added support for M1 GPU as of 2022-05-18 in the Nightly version. Read more about it in their blog post.
Simply install nightly:
conda install pytorch -c pytorch-nightly --force-reinstall
To use (source):
mps_device = torch.device(&quot;mps&quot;)

# Create a Tensor directly on the mps device
x = torch.ones(5, device=mps_device)
# Or
x = torch.ones(5, device=&quot;mps&quot;)

# Any operation happens on the GPU
y = x * 2

# Move your model to mps just like any other device
model = YourFavoriteNet()
model.to(mps_device)

# Now every call runs on the GPU
pred = model(x)

