【问题标题】:Why i am getting "terminate called after throwing an instance of 'std::bad_alloc'' when my training data is large?当我的训练数据很大时,为什么我在抛出 'std::bad_alloc' 的实例后被调用终止?
【发布时间】:2019-10-31 16:52:26
【问题描述】:

我的硬件是 Intel Pentium,8 GB RAM,250 GB 硬盘,没有 GPU。我能够用 400 张图像训练数据,但是当我将图像数量增加到 1000 时,它会抛出错误

<pre>2019-10-31 21:55:05.844961: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2
terminate called after throwing an instance of &apos;std::bad_alloc&apos;
  what():  std::bad_alloc
Aborted (core dumped)
</pre>

如何解决这个问题?

【问题讨论】:

    标签: python tensorflow gpu


    【解决方案1】:

    该错误意味着您的内存不足。

    特殊注意事项:

    在某些情况下,这可能是由内存碎片引起的,因为您实际上有足够的内存来服务您的任务,但由于它不连续,因此无法使用。

    或者

    一个进程被分配了一个很大的内存部分,其中一些未被占用并且不能被另一个进程使用。

    在训练之间运行 tf.reset_default_graph() 可能有助于释放内存,以防万一碎片是真正的问题。
    keras.clear_session() 方法是 tf.reset_default_graph() 的替代方法,它可能有助于在出现碎片时释放内存。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多