系统内存不足,XX的分配超出了系统内存的10%

时间:2019-06-11 02:14:52

标签: python tensorflow memory

我正在使用tensorflow(2.0版Alpha)训练自动编码器,即使将批大小设置为2,我的内存也已耗尽(已分配的10%的内存)。

我正在运行以下代码:

with tf.compat.v1.Session() as sess:

    sess.run(tf.compat.v1.global_variables_initializer())

    for epoch_i in range(epochs):

        for batch_i in range(number_of_batches_train):

            batch_data_train = getBatch(aug_data_train, batch_i, batch_size)
            sess.run(optimizer, feed_dict={x1: batch_data_train[:,:,0], X: batch_data_train}) #complex warning

        #Here is where the problem is
        loss_train = sess.run(loss, feed_dict={x1: aug_data_train[:,:,0], X: aug_data_train})
        loss_validate = sess.run(loss,feed_dict={x1: aug_data_validate[:,:,0], X: aug_data_validate})

        print(epoch_i, loss_train)

并出现以下错误:

2019-06-11 03:58:14.883251: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2019-06-11 03:58:14.915905: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 2899835000 Hz
2019-06-11 03:58:14.916053: I tensorflow/compiler/xla/service/service.cc:162] XLA service 0x5e656f0 executing computations on platform Host. Devices:
2019-06-11 03:58:14.916073: I tensorflow/compiler/xla/service/service.cc:169]   StreamExecutor device (0): <undefined>, <undefined>
Epoch Loss
/cluster/home/tmarta/.local/lib/python3.6/site-packages/numpy/core/numeric.py:538: ComplexWarning: Casting complex values to real discards the imaginary part
  return array(a, dtype, copy=False, order=order)
2019-06-11 03:59:02.987351: W tensorflow/core/framework/allocator.cc:116] Allocation of 1910988800 exceeds 10% of system memory.
Killed

有人对如何解决此问题有想法吗?我已经阅读了许多与此主题相关的问题,但是没有一个问题解决了我的问题……谢谢!

0 个答案:

没有答案