TensorFlow 对象检测 API - 内存不足

TensorFlow Object Detection API - Out of Memory

我正在使用 Tensorflow 对象检测 API 来训练我自己的对象检测器。我从模型动物园(here)下载了faster_rcnn_inception_v2_coco_2018_01_28,并制作了我自己的数据集(train.record(~221Mo),test.record和标签图)来微调它.

但是当我 运行 它时 :

python train.py --logtostderr --pipeline_config_path=/home/username/Documents/Object_Detection/training/faster_rcnn_inception_v2_coco_2018_01_28/pipeline.config --train_dir=/home/username/Documents/Object_Detection/training/

进程在填充shuffle buffer操作期间被杀死,看起来像一个OOM问题(16Go RAM)...

2018-06-07 12:02:51.107021: I tensorflow/core/kernels/data/shuffle_dataset_op.cc:94] Filling up shuffle buffer (this may take a while): 410 of 2048
Process stopped

是否存在减少洗牌缓冲区大小的方法?它的大小有什么影响?

然后,我添加了一些交换(115Go 交换 + 16Go RAM)并完成了填充洗牌缓冲区操作,但是我的训练在第 4 步之后占用了所有 RAM 和交换,而我的 train.record 大约是 221莫!

我已经将这些行添加到我的 pipeline.config > train_config:

batch_size: 1
batch_queue_capacity: 10
num_batch_queue_threads: 8
prefetch_queue_capacity: 9

还有这些给我的 pipeline.config > train_input_reader :

queue_capacity: 2
min_after_dequeue: 1
num_readers: 1

关注此 post

我知道我的图片非常(非常非常)大:每张 25Mo,但是因为我只拍了 9 张图片来制作我的 train.record(只是为了测试我的安装是否顺利),所以不应该这么耗内存吧?

关于它为什么使用这么多 RAM 的任何其他想法?

(顺便说一句,我只使用 CPU)

图片数量不是问题。问题是您的输入图像分辨率(在您的设置 .config 文件中)。您需要在此处更改高度和宽度值(类似于您的 .config 文件):

image_resizer {
  # TODO(shlens): Only fixed_shape_resizer is currently supported for NASNet
  # featurization. The reason for this is that nasnet.py only supports
  # inputs with fully known shapes. We need to update nasnet.py to handle
  # shapes not known at compile time.
  fixed_shape_resizer {
    height: 1200
    width: 1200
  }
}

将宽度和高度设置为较小的值,您将能够完美地训练。