0
点赞
收藏
分享

微信扫一扫

macOS M1使用TensorFlow GPU加速

本人是在pycharm运行代码,安装了tensorflow版本2.13.0

先运行代码查看有没有使用GPU加速:

import tensorflow as tf


# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    physical_devices = tf.config.list_physical_devices('GPU')
    print("Num GPUs:", len(physical_devices))

如果运行结果为0,则没有使用GPU加速训练。

根据官网,安装了适用于 macOS GPU 的Metal PluggableDevice,在pycharm的terminal输入命令:

python3 -m pip install tensorflow-metal

安装成功后,再次运行顶部代码:

 

 

运行结果GPU数量是1,安装成功了!

举报

相关推荐

0 条评论