【发布时间】:2020-06-29 12:14:25
【问题描述】:
我想用 graphcore IPU 测试性能,但我不知道如何使用 tensorflow。有人可以帮我做这件事吗?
【问题讨论】:
标签: python tensorflow artificial-intelligence ipu
我想用 graphcore IPU 测试性能,但我不知道如何使用 tensorflow。有人可以帮我做这件事吗?
【问题讨论】:
标签: python tensorflow artificial-intelligence ipu
Graphcore Poplar SDK 包含两个轮子文件,用于安装适用于 Python 3 的 v1.15 或 v2.1 TensorFlow 的 Graphcore 端口。您应该在虚拟环境中安装两个轮子文件之一,然后您需要再执行几个步骤即可在 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 的主要介绍。您还可以参考 to this document 作为在 IPU 上移植 TensorFlow 模型的实用指南,并提供一些最佳实践指南。
【讨论】: