主要ref:苹果开发者官网 - tensorflow配置
重点是注意tensorflow-metal、tensorflow和python的版本!
tensorflow | tensorflow-metal | MacOs | features |
---|---|---|---|
v2.5 | v0.1.2 | 12.0+ | Pluggable device |
v2.6 | v0.2.0 | 12.0+ | Variable seq. length RNN |
v2.7 | v0.3.0 | 12.0+ | Custom op support |
v2.8 | v0.4.0 | 12.0+ | RNN perf. improvements |
v2.9 | v0.5.0 | 12.1+ | Distributed training |
v2.10 | v0.6.0 | 12.1+ | |
v2.11 | v0.7.0 | 12.1+ | |
v2.12 | v0.8.0 | 12.1+ | |
v2.13 | v1.0.0 | 12.1+ | FP16 and BF16 support |
v2.14 | v1.1.0 | 12.1+ |
tensorflow和python对应版本(后面测试我高版本python3.11也可以)
- 安装conda(省略,也可以不使用conda)
- conda查看可以安装的python版本
conda search python
- 如果没有想要的太低版本,需要添加conda源啥的;
- 我Macbook M3 pro测试了python3.11 + tf 2.14 + tf-metal v.1.1.0是可以运行的
- conda创造指定python版本的环境:
conda create -n tf-metal python=3.11.8
- conda选择刚创建的环境:
conda activate tf-metal
- pip下载tf:
pip install tensorflow==2.14
- pip下载tf-metal:
pip install tensorflow-metal==1.1.0
- 下载jupyter notebook(或者直接跳到step10运行python代码):
conda install jupyter notebook
- 运行jupyter notebook:
jupyter notebook
- 如果运行失败显示了下面的错误,安装chardet:
pip install chardet
Traceback (most recent call last): File
“/opt/miniconda3/envs/tf-metal/lib/python3.11/site-packages/requests/compat.py”,
line 11, in
import chardet ModuleN
- 如果运行失败显示了下面的错误,安装chardet: