在Apple M1芯片上安装PyTorch和TensorFlow(GPU版)

1、安装TensorFlow(GPU版)

xcode-select --install

conda create -n tf-mac-gpu python=3.8

conda activate tf-mac-gpu

conda install -c apple tensorflow-deps

pip install tensorflow-macos

pip install tensorflow-metal

conda install jupyter notebook

更新包:

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

2、安装pytorch(GPU版)

xcode-select --install

conda create -n torch-mac-gpu python=3.8

conda activate torch-mac-gpu

conda install pytorch torchvision torchaudio -c pytorch-nightly

conda install jupyter notebook

3、测试对比结果

3.1 TensorFlow使用kaggle上dog-vs-cat分割数据,速度是使用Mac CPU的6-7倍。

3.2 pytorch只测试了MNIST,速度是使用Mac CPU的2.5倍。

Apple给的对比数据:experiments-and-benchmarks-for-m1

4、主要参考链接:

4.1、install-tensorflow-on-mac-m1-m2-with-gpu

4.2、installing-pytorch-on-apple-m1-chip-with-gpu

4.3、no-module-named-tensorflow-in-jupyter

你可能感兴趣的:(machine,learning,deep,learning,MacBook,GPU,人工智能,macos)