栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

MacOS Apple M1上安装tensorflow2使用其原生GPU

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

MacOS Apple M1上安装tensorflow2使用其原生GPU

安装Mambaforge

首选推荐安装Mambaforge, 也可以安装miniforge3。
项目链接:https://github.com/conda-forge/miniforge/

创建conda虚拟环境
conda create -n tf270 -c apple tensorflow-deps
conda activate tf270
pip install tensorflow-macos tensorflow-metal
测试安装是否成功
import tensorflow as tf
print(tf.__version__)
print(tf.version.VERSION)

from tensorflow.python.client import device_lib
print(device_lib.list_local_devices())

结果如下GPU即为安装成功:

(tf270) hzw@bogon ~ % python                                        
Python 3.9.7 | packaged by conda-forge | (default, Sep 29 2021, 19:24:02) 
[Clang 11.1.0 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from tensorflow.python.client import device_lib
>>> print(device_lib.list_local_devices())
metal device set to: Apple M1

systemMemory: 8.00 GB
maxCacheSize: 2.67 GB

2021-12-15 16:38:14.922342: I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:305] Could not identify NUMA node of platform GPU ID 0, defaulting to 0. Your kernel may not have been built with NUMA support.
2021-12-15 16:38:14.923134: I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:271] Created TensorFlow device (/device:GPU:0 with 0 MB memory) -> physical PluggableDevice (device: 0, name: metaL, pci bus id: )
[name: "/device:CPU:0"
device_type: "CPU"
memory_limit: 268435456
locality {
}
incarnation: 16585735293412376744
xla_global_id: -1
, name: "/device:GPU:0"
device_type: "GPU"
locality {
  bus_id: 1
}
incarnation: 17634086545751551048
physical_device_desc: "device: 0, name: metaL, pci bus id: "
xla_global_id: -1
]
>>> 
参考链接

https://developer.apple.com/metal/tensorflow-plugin/

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/665349.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号