
[英]Tensorflow MNIST: terminate called after throwing an instance of 'std::bad_alloc'
[英]Why i am getting "terminate called after throwing an instance of 'std::bad_alloc'' when my training data is large?
我的硬件是 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 'std::bad_alloc'
what(): std::bad_alloc
Aborted (core dumped)
</pre>
如何解决这个问题?
该错误意味着您用完了 memory。
特殊考虑:
在某些情况下,它可能是由 memory 碎片引起的,因为您实际上有足够的 memory 来为您的任务提供服务,但由于它不连续,因此无法使用。
或者
一个进程被分配了一个大的 memory 部分,其中一些未被占用并且不能被另一个进程使用。
在训练之间运行tf.reset_default_graph()
可能有助于释放 memory 以防万一碎片是真正的问题。
keras.clear_session()
方法是tf.reset_default_graph()
() 的替代方法,它可能有助于在出现碎片的情况下释放 memory。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.