np.array MemoryError与tf.data.Dataset.from_generator

时间:2019-05-12 06:01:01

标签: python numpy tensorflow

我正在尝试使用文本压缩数据(Gigaword)https://github.com/Kyubyong/transformer运行此自定义Transformer模型。

我已经在tensorflow-gpu 1.13.1上以cuDNN 7.4.1 / cuda 10.0 / ubuntu 16.04运行了这段代码。

,但要继续面对类似错误的错误。

我已经使用tensorflow-cpu在MacOSX上成功运行了代码,但是,当我尝试在gpu服务器上训练数据时,它将返回错误。

我试图将tf.int32更改为tf.int64,但是它不起作用。(print(np.intp returns 64

我对RAM shortage表示怀疑,因此请使用free -m命令跟踪内存的实时变化,但是它永远不会耗尽整个内存(我的ubuntu上有16GB的内存服务器)

可能是什么问题?

INFO:root:# hparams
INFO:root:# Prepare train/eval batches
Traceback (most recent call last):
  File "/home/zachary/projects/transformer/train.py", line 36, in <module>
    shuffle=True)
  File "/home/zachary/projects/transformer/data_load.py", line 160, in get_batch
    batches = input_fn(sents1, sents2, vocab_fpath, batch_size, shuffle=shuffle)
  File "/home/zachary/projects/transformer/data_load.py", line 125, in input_fn
    args=(sents1, sents2, vocab_fpath))  # <- arguments for generator_fn. converted to np string arrays
  File "/home/zachary/.local/lib/python3.5/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 1461, in from_generator
    generator, output_types, output_shapes, args))
  File "/home/zachary/.local/lib/python3.5/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 408, in from_generator
    args = tuple(ops.convert_n_to_tensor(args, name="args"))
  File "/home/zachary/.local/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 1273, in convert_n_to_tensor
    as_ref=False)
  File "/home/zachary/.local/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 1240, in internal_convert_n_to_tensor
    ctx=ctx))
  File "/home/zachary/.local/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 1175, in internal_convert_to_tensor
    ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
  File "/home/zachary/.local/lib/python3.5/site-packages/tensorflow/python/framework/constant_op.py", line 304, in _constant_tensor_conversion_function
    return constant(v, dtype=dtype, name=name)
  File "/home/zachary/.local/lib/python3.5/site-packages/tensorflow/python/framework/constant_op.py", line 245, in constant
    allow_broadcast=True)
  File "/home/zachary/.local/lib/python3.5/site-packages/tensorflow/python/framework/constant_op.py", line 283, in _constant_impl
    allow_broadcast=allow_broadcast))
  File "/home/zachary/.local/lib/python3.5/site-packages/tensorflow/python/framework/tensor_util.py", line 467, in make_tensor_proto
    nparray = np.array(values, dtype=np_dt)
MemoryError

0 个答案:

没有答案