python - 如何将 tensorflow 与 Graphcore IPU 一起使用
问题描述
我想用graphcore IPU测试性能,但我不知道怎么用tensorflow。有人可以帮我做到这一点吗?
解决方案
Graphcore Poplar SDK 包含两个 wheel 文件,用于安装适用于 Python 3 的 v1.15 或 v2.1 TensorFlow 的 Graphcore 端口。您应该在虚拟环境中安装两个 wheel 文件之一,然后您将需要更多能够在 IPU 设备上运行模型的步骤。
根据应用程序,需要将一些特定于 IPU 的模块导入添加到您的程序中:
from tensorflow.python.ipu import utils, ipu_compiler, scopes, loops, ipu_infeed_queue, ipu_outfeed_queue
您必须确保通过将 TensorFlow 图放置在 IPU 设备上来以 Graphcore IPU 硬件为目标,并删除代码中可能包含的任何 CPU/GPU/TPU 特定选项。然后,您可以使用自定义 IPU 编译器来编译 TensorFlow 图:
with scopes.ipu_scope("/device:IPU:0"):
compiled = ipu_compiler.compile(training_loop)
下一步是配置 IPU 设备:基本配置将包括定义您希望模型在多少个 IPU 上运行。假设您只需要一个 IPU:
config = utils.create_ipu_config()
config = utils.auto_select_ipus(config, [1])
utils.configure_ipu_system(config)
我建议阅读相关参考指南Targeting the IPU from TensorFlow作为 TensorFlow-to-Poplar API 的主要介绍。您还可以参考本文档作为在 IPU 上移植 TensorFlow 模型的实用指南,并提供一些最佳实践指南。
推荐阅读
- javascript - Firebase FCM(Javascript):请求权限时出错(错误状态 = 500)
- python - 与树莓派和 arduino 的 I2C 通信问题
- azure - 如何从 Azure 环境中获取 PowerShell Az 模块版本
- latex - 表格单元格内的项目符号列表
- mysql - ESP8266 和 mySQL
- git - 使用 http://username:password@server 的 Git Pull 仍然要求提供凭据?
- java - 将字符串数组返回到其他类(包括继承)并打印
- c# - 这是火与遗忘?(Linq 到 SQL)
- python - 困惑为什么在应用 pd.to_numeric 时列不会更改为数字类型
- html - 如何将 div 排列成两行三列,由偶数和奇数子分隔?