Macbook M1安装tensorflow-gpu教程

macbook M1安装tensorflow-gpu教程:https://developer.apple.com/metal/tensorflow-plugin/

chmod +x ~/Downloads/Miniforge3-MacOSX-arm64.sh
sh ~/Downloads/Miniforge3-MacOSX-arm64.sh
一路yes即可
# source ~/miniforge3/bin/activate
source /Applications/Software/miniforge3/bin/activate
conda create -n tensorflow-gpu pip python=3.9
source activate tensorflow-gpu
conda install -c apple tensorflow-deps
conda install -c apple tensorflow-deps==2.6.0
python -m pip install tensorflow-macos
python -m pip install tensorflow-metal

测试代码:

import tensorflow as tf
print(tf.__version__)

#加载mnist数据集
mnist = tf.keras.datasets.mnist
(x_train, y_train), (x_test, y_test) = mnist.load_data()

model = tf.keras.models.Sequential([
    tf.keras.layers.Flatten(input_shape=[28, 28]),
    tf.keras.layers.Dense(128, activation='relu'),
    tf.keras.layers.Dropout(0.2),
    tf.keras.layers.Dense(10, activation='softmax')
])

#编译
model.compile(optimizer='adam',
            loss='sparse_categorical_crossentropy',
            metrics=['accuracy'])
#训练模型
model.fit(x_train, y_train, epochs=5, batch_size=64)
model.evaluate(x_test, y_test)

labelme安装

conda create --name=labelme python=3.9
conda activate labelme
pip install pyqt5 
pip install labelme
source activate labelme
labelme

你可能感兴趣的:(深度学习,mac,深度学习,tensorflow)