Tensorflow 程序使用哪个内存来存储数据?

Which memory does the Tensorflow programs use to store the data?

我认为是以下情况。

  1. 使用带有 GPU 的 Tensorflow 制作 ML 模型以解决图像分类问题
  2. 加载图片,使用pillow,预处理,使用numpy
  3. ML 模型获取 tf.placeholder
  4. 中的输入数据

我知道 tensorflow-gpu 在可能的情况下使用 GPU 上的 RAM 来默认存储参数。但是对于传递到tf.placeholder之前的输入数据,它存储在哪个RAM中,CPU的RAM还是GPU的?

根据定义 placeholder has no data until fed. Making many assumptions here, unless you copy your data to GPU memory in its entirety via tf.constant() 如果您的数据集适合可用的 GPU 内存,则可以完成此操作,数据存在于 CPU/system 内存中,需要复制到 GPU 内存中。

根据您在第 1 步和第 2 步中的描述,它看起来有点像 here.

中描述的原始 implementation/lack 流水线

However, in a naive synchronous implementation, while the CPU is preparing the data, the accelerator is sitting idle. Conversely, while the accelerator is training the model, the CPU is sitting idle. The training step time is thus the sum of both CPU pre-processing time and the accelerator training time.

在训练步骤之前,您的数据存在于 CPU/system 内存中。