繁体   English   中英

在 MacBook Pro 上使用 pytorch Cuda

[英]Using pytorch Cuda on MacBook Pro

我使用的是 MacBook Pro(16 英寸,2019,macOS 10.15.5 (19F96))

GPU

  • AMD Radeon Pro 5300M
  • 英特尔超高清显卡 630

我正在尝试在我的 Mac 上使用 Pytorch 和 Cuda。

我看到的所有指南都假设我有 Nvidia 显卡。

我发现了这个: https://github.com/pytorch/pytorch/issues/10657问题,但看起来我需要安装 ROCm,并且根据他们的Supported Operating Systems ,它只支持 Linux。

是否可以使用 mac 和 AMD 显卡在 GPU 上运行 Pytorch?

不。

CUDA 仅适用于支持的 NVidia GPU,不适用于 AMD GPU。

正在努力通过 PyTorch 支持 AMD GPU 的加速(通过 ROCm,这在 MacOS 上不起作用)。

CUDA 是 nVidia 为 nVidia GPU 开发的 GPU 计算框架。 此外,CuDNN 框架也是如此。

目前,您不能将 GPU 加速与 PyTorch 与 AMD GPU 一起使用,即没有 nVidia Z52F91EC21735277DA329。 操作系统不是问题,也就是说,您拥有 macOC 并不重要。 这取决于您拥有什么 GPU。

不过,您可以做的是,您可以购买外部 nVidia GPU 或使用一些集群。 例如,Google Colab 提供 PyTorch 兼容性。

不幸的是,在 macOS 上使用 Pytorch 时,没有 GPU 加速可用。 CUDA 暂时无法在 macOS 上使用,它只能在 NVIDIA GPU 上运行。 AMD 的等效库 ROCm 需要 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.

目前,您需要 Python 3.8(<=3.7 和 >=3.9 不起作用)来运行它。 要安装,请运行:

pip3 install tensorflow-macos
pip3 install tensorflow-metal

您可能需要先卸载现有的 tensorflow 发行版或在虚拟环境中工作。

然后你可以

import tensorflow as tf

tf.test.is_gpu_available()  # should return True

这将在 4 个月内,即 2022 年 3 月左右。请参阅 Soumith 在 GitHub 上对此问题的回复。 https://github.com/pytorch/pytorch/issues/47702

不幸的是 CUDA 仅适用于支持的 NVidia GPU

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM