Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using pytorch Cuda on MacBook Pro

Tags:

macos

pytorch

I am using MacBook Pro (16-inch, 2019, macOS 10.15.5 (19F96))

GPU

  • AMD Radeon Pro 5300M
  • Intel UHD Graphics 630

I am trying to use Pytorch with Cuda on my mac.

All of the guides I saw assume that i have Nvidia graphic card.

I found this: https://github.com/pytorch/pytorch/issues/10657 issue, but it looks like I need to install ROCm, and according to their Supported Operating Systems, it only supports Linux.

Is it possible to run Pytorch on GPU using mac and AMD Graphic card?

like image 692
Kenny Smith Avatar asked Sep 11 '25 23:09

Kenny Smith


2 Answers

PyTorch now supports training using Metal.

Announcement: https://pytorch.org/blog/introducing-accelerated-pytorch-training-on-mac/

To get started, install the latest nightly build of PyTorch: https://pytorch.org/get-started/locally/


Answer pre May 2022

Unfortunately, no GPU acceleration is available when using Pytorch on macOS. CUDA has not available on macOS for a while and it only runs on NVIDIA GPUs. AMDs equivalent library ROCm requires Linux.

If you are working with macOS 12.0 or later and would be willing to use TensorFlow instead, you can use the Mac optimized build of TensorFlow, which supports GPU training using Apple's own GPU acceleration library Metal.

Currently, you need Python 3.8 (<=3.7 and >=3.9 don't work) to run it. To install, run:

pip3 install tensorflow-macos
pip3 install tensorflow-metal

You may need to uninstall existing tensorflow distributions first or work in a virtual environment.

Then you can just

import tensorflow as tf

tf.test.is_gpu_available()  # should return True
like image 135
Palle Avatar answered Sep 14 '25 17:09

Palle


No.

CUDA works only with supported NVidia GPUs, not with AMD GPUs.

There is an ongoing effort to support acceleration for AMD GPUs with PyTorch (via ROCm, which does not work on MacOS).

like image 32
Sergii Dymchenko Avatar answered Sep 14 '25 17:09

Sergii Dymchenko