如何 运行 Pytorch on Macbook pro (M1) GPU?
How to run Pytorch on Macbook pro (M1) GPU?
我尝试在我的 Macbook pro 上使用 PyTorch 训练模型。它使用新一代苹果M1CPU。但是,PyTorch 无法识别我的 GPU。
GPU available: False, used: False
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
有人知道解决办法吗?
我已经将所有库更新到最新版本。
看起来 PyTorch 对 M1 GPU 的支持正在开发中,但尚未完成。
从 @soumith 到 GitHub:
So, here's an update.
We plan to get the M1 GPU supported. @albanD, @ezyang and a few core-devs have been looking into it. I can't confirm/deny the involvement of any other folks right now.
So, what we have so far is that we had a prototype that was just about okay. We took the wrong approach (more graph-matching-ish), and the user-experience wasn't great -- some operations were really fast, some were really slow, there wasn't a smooth experience overall. One had to guess-work which of their workflows would be fast.
So, we're completely re-writing it using a new approach, which I think is a lot closer to your good ole PyTorch, but it is going to take some time. I don't think we're going to hit a public alpha in the next ~4 months.
We will open up development of this backend as soon as we can.
那个post:
https://github.com/pytorch/pytorch/issues/47702#issuecomment-965625139
TL;DR:public 测试版至少要发布 4 个月。
自 2022 年 5 月 18 日起,PyTorch 在 Nightly 版本中添加了对 M1 GPU 的支持。在他们的 blog post.
中阅读更多相关信息
只需每晚安装:
conda install pytorch -c pytorch-nightly --force-reinstall
要使用 (source):
mps_device = torch.device("mps")
# Create a Tensor directly on the mps device
x = torch.ones(5, device=mps_device)
# Or
x = torch.ones(5, device="mps")
# 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)
对于像我一样无法使用conda
安装的用户,请使用pip
,如下所示:-
要求:
- 任何配备苹果硅芯片的 Macbook
- macOS 版本 12.3+
安装:
pip3 install --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cpu
用法:
请确保您使用 mps
作为您的设备,如下所示:
device = torch.device('mps')
# Send you tensor to GPU
my_tensor = my_tensor.to(device)
基准测试(在 M1 Max、10 核 CPU、24 核 GPU 上):
不使用GPU
使用 GPU (快 5 倍)
我尝试在我的 Macbook pro 上使用 PyTorch 训练模型。它使用新一代苹果M1CPU。但是,PyTorch 无法识别我的 GPU。
GPU available: False, used: False
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
有人知道解决办法吗?
我已经将所有库更新到最新版本。
看起来 PyTorch 对 M1 GPU 的支持正在开发中,但尚未完成。
从 @soumith 到 GitHub:
So, here's an update. We plan to get the M1 GPU supported. @albanD, @ezyang and a few core-devs have been looking into it. I can't confirm/deny the involvement of any other folks right now.
So, what we have so far is that we had a prototype that was just about okay. We took the wrong approach (more graph-matching-ish), and the user-experience wasn't great -- some operations were really fast, some were really slow, there wasn't a smooth experience overall. One had to guess-work which of their workflows would be fast.
So, we're completely re-writing it using a new approach, which I think is a lot closer to your good ole PyTorch, but it is going to take some time. I don't think we're going to hit a public alpha in the next ~4 months.
We will open up development of this backend as soon as we can.
那个post: https://github.com/pytorch/pytorch/issues/47702#issuecomment-965625139
TL;DR:public 测试版至少要发布 4 个月。
自 2022 年 5 月 18 日起,PyTorch 在 Nightly 版本中添加了对 M1 GPU 的支持。在他们的 blog post.
中阅读更多相关信息只需每晚安装:
conda install pytorch -c pytorch-nightly --force-reinstall
要使用 (source):
mps_device = torch.device("mps")
# Create a Tensor directly on the mps device
x = torch.ones(5, device=mps_device)
# Or
x = torch.ones(5, device="mps")
# 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)
对于像我一样无法使用conda
安装的用户,请使用pip
,如下所示:-
要求:
- 任何配备苹果硅芯片的 Macbook
- macOS 版本 12.3+
安装:
pip3 install --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cpu
用法:
请确保您使用 mps
作为您的设备,如下所示:
device = torch.device('mps')
# Send you tensor to GPU
my_tensor = my_tensor.to(device)
基准测试(在 M1 Max、10 核 CPU、24 核 GPU 上):
不使用GPU
使用 GPU (快 5 倍)