You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

2019款MacBook Pro中TensorFlow无法识别GPU,如何启用GPU加速?

问题解决:Intel核显Mac上TensorFlow无法识别GPU的处理方案

你的2019款MacBook Pro搭载的是Intel Iris Plus Graphics 645核显,而tensorflow-metal仅支持Apple Silicon(M系列)芯片,这是TensorFlow无法识别GPU的核心原因。以下是针对Intel核显Mac的可行解决方案:

一、卸载无用的tensorflow-metal

先移除对Intel芯片无效的tensorflow-metal,避免包冲突:

pip uninstall tensorflow-metal -y

二、安装Intel TensorFlow扩展实现核显加速

Intel官方提供了针对自家CPU/GPU的TensorFlow扩展,可启用核显加速:

  1. 激活你的虚拟环境
  2. 安装Intel Extension for TensorFlow:
    pip install intel-extension-for-tensorflow[cpu]
    

    注:该包会自动适配Intel核显,无需额外安装完整oneAPI toolkit(基础依赖会自动部署)

三、验证GPU识别

运行以下代码验证是否成功识别Intel核显:

import tensorflow as tf
import intel_extension_for_tensorflow as itex

# 切换到Intel GPU后端
itex.set_backend("gpu")

# 查看识别到的物理设备
print(tf.config.list_physical_devices())

正常输出会包含类似PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')的条目,代表Intel核显已被识别。

注意事项

  • Intel核显的TensorFlow加速性能虽不如Apple Silicon的Metal加速,但相比纯CPU仍有一定提升
  • 确保你的macOS版本在Big Sur 11.0及以上,TensorFlow版本为2.10及以上(推荐2.15稳定版)

内容的提问来源于stack exchange,提问作者Ronit Akhariya

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.27 03:54:58