哪些张量流操作触发内存分配?
Which tensorflow operations trigger memory allocation?
阅读 TensorArray class 的文档后,我遇到了这一行:
If True, the TensorArray will be colocated on the same device as the Tensor used on its first write (write operations include write, unstack, and split). If False, the TensorArray will be placed on the device determined by the device context available during its initialization.
这让我想知道是否只有某些操作会触发实际的内存分配和 reading/writing 以及是否有这些操作的列表。
我也想知道这一点,因为在创建暂时非常大的张量时由于 OOM 错误而存在限制,但无论如何都是以批处理的方式处理的,因此程序永远不需要实际保存所有数据张量 - 类似于数据集 API 允许处理 无限 大型数据集,因为所有内容都是按需加载的。
从 Tensorflow-GPU 的角度来看:没有列表。
TF 在 GPU 上 运行 有两种方式:
- 没有 XLA
- 使用 XLA
没有 XLA,一旦操作 A0 完成,tensorflow 将根据 A0 分配所有操作的内存:B0、B1、B2 等。一旦这些操作完成,TF 将释放不再需要的 A0 内存。如果你有卷积神经网络,你通常会保存所有前向路径激活,直到反向路径开始。
使用 XLA,可以将多个操作合并到块中。在块内,操作可以是 merged/split/duplicated 以减少内存使用。 XLA 集群会有自己的内存管理例程,这取决于操作是如何混合在一起的。多个 XLA 集群将表现为多个非 XLA 操作:它们将尽快启动,可能导致次优的峰值内存使用。
阅读 TensorArray class 的文档后,我遇到了这一行:
If True, the TensorArray will be colocated on the same device as the Tensor used on its first write (write operations include write, unstack, and split). If False, the TensorArray will be placed on the device determined by the device context available during its initialization.
这让我想知道是否只有某些操作会触发实际的内存分配和 reading/writing 以及是否有这些操作的列表。
我也想知道这一点,因为在创建暂时非常大的张量时由于 OOM 错误而存在限制,但无论如何都是以批处理的方式处理的,因此程序永远不需要实际保存所有数据张量 - 类似于数据集 API 允许处理 无限 大型数据集,因为所有内容都是按需加载的。
从 Tensorflow-GPU 的角度来看:没有列表。
TF 在 GPU 上 运行 有两种方式:
- 没有 XLA
- 使用 XLA
没有 XLA,一旦操作 A0 完成,tensorflow 将根据 A0 分配所有操作的内存:B0、B1、B2 等。一旦这些操作完成,TF 将释放不再需要的 A0 内存。如果你有卷积神经网络,你通常会保存所有前向路径激活,直到反向路径开始。
使用 XLA,可以将多个操作合并到块中。在块内,操作可以是 merged/split/duplicated 以减少内存使用。 XLA 集群会有自己的内存管理例程,这取决于操作是如何混合在一起的。多个 XLA 集群将表现为多个非 XLA 操作:它们将尽快启动,可能导致次优的峰值内存使用。