Mac GPU MPS常用方法

Requirements

Mac computers with Apple silicon or AMD GPUs
macOS 12.3 or later
Python 3.7 or later
Xcode command-line tools: xcode-select --install

判断是否可用

import torch
if torch.backends.mps.is_available():
    mps_device = torch.device("mps")
    x = torch.ones(1, device=mps_device)
    print (x)
else:
    print ("MPS device not found.")

你可能感兴趣的:(深度学习,macos)