Macbook Pro M1 max Apple Silicon MacOSX 13.4.1 安装Tensorflow

前置条件:homebrew

 

1.在终端输入命令行,安装mini forge.

brew install miniforge

2.创建tensorflow运行环境,同时在该运行环境中安装python,截止2023年7月26日,tensorflow支持到python3.11以前的版本。

conda create -n tf "python<3.11"

3.进入创建的tensorflow运行环境。

conda activate tf

4.安装apple tensorflow-deps

conda install -c apple tensorflow-deps

5.更新pip,安装tensorflow-macos

pip install --upgrade pip
pip install tensorflow-macos

6.安装Metal-plugin

pip install tensorflow-metal

7.安装tensorflow-dataset

pip install tensorflow_datasets

8.安装Jupyterlab

conda install jupyterlab -y

9.安装其他运行库

pip install numpy  --upgrade
pip install pandas  --upgrade
pip install matplotlib  --upgrade
pip install scikit-learn  --upgrade
pip install scipy  --upgrade
pip install plotly  --upgrade
pip install transformers datasets --upgrade

10.检查GPU支持 

import sys
import keras
import pandas as pd
import sklearn as sk
import scipy as sp
import tensorflow as tf
import platform
print(f"Python Platform: {platform.platform()}")
print(f"Tensor Flow Version: {tf.__version__}")
print(f"Keras Version: {keras.__version__}")
print()
print(f"Python {sys.version}")
print(f"Pandas {pd.__version__}")
print(f"Scikit-Learn {sk.__version__}")
print(f"SciPy {sp.__version__}")
gpu = len(tf.config.list_physical_devices('GPU'))>0
print("GPU is", "available" if gpu else "NOT AVAILABLE")

 

posted @ 2023-07-27 06:52  芬尼克斯  阅读(162)  评论(0编辑  收藏  举报