安装 Xcode
xcode-select --install
创建环境
conda create -n torch-gpu python=3.9conda activate torch-gpu
打开pytorch官网复制命令, 注意:在mac m上,device是’mps’ 而不是’cuda’, mac的MPS支持MacOS 12.3+
4.测试
import torchimport mathprint(torch.backends.mps.is_available())# Trueprint(torch.backends.mps.is_built())# True
安装 Xcode
xcode-select --install
创建环境
conda create -n tensorflow-gpu python=3.9conda activate tensorflow-gpu
安装conda install -c apple tensorflow-deps
conda install -c apple tensorflow-deps
4.Install base TensorFlow
python -m pip install tensorflow-macos==2.9
Install tensorflow-metal plug-in
python -m pip install tensorflow-metal==0.6
6.验证
import tensorflow as tfprint(tf.test.is_gpu_available())
完成,附上我安装完pytorch和tensorflow的图
来源地址:https://blog.csdn.net/xiangfengl/article/details/130940480