Mac M1集成TensorFlow GPU遇tensorflow-deps包找不到问题求助
M1 Mac安装TensorFlow GPU(tensorflow-deps找不到)解决办法
方案一:调整conda渠道并指定兼容版本
- 先清理可能冲突的旧渠道配置:
conda config --remove channels appleconda config --remove channels conda-forge - 添加苹果官方渠道,安装和Anaconda 2022.3.1适配性最好的2.10.0版本tensorflow-deps:
conda config --add channels appleconda install -c apple tensorflow-deps==2.10.0
方案二:放弃Anaconda,用原生Python+Homebrew安装
如果conda渠道问题始终无法解决,换这套更稳定的流程:
- 安装Xcode命令行工具:
xcode-select --install - 安装Homebrew(未安装过的话):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" - 依次安装依赖和TensorFlow核心包:
brew install tensorflow-depspython -m pip install tensorflow-macos==2.10.0python -m pip install tensorflow-metal==0.6.0
方案三:重建干净的conda虚拟环境
旧环境可能存在残留冲突,直接新建一个:
- 创建并激活Python 3.9版本的虚拟环境(M1适配最佳):
conda create -n tf-gpu python=3.9conda activate tf-gpu - 安装指定版本的tensorflow-deps:
conda install -c apple tensorflow-deps==2.10.0
验证安装是否成功
激活环境后运行以下代码:
import tensorflow as tf print(tf.__version__) print(tf.config.list_physical_devices('GPU'))
输出中出现Metal GPU相关条目,即说明安装成功。
内容的提问来源于stack exchange,提问作者Christopher Gaughan
相关产品推荐
相关产品推荐

