简体   繁体   English

MemoryError张量流

[英]MemoryError tensorflow

I'm running this model from AWS instance of type P2.xlarge. 我正在从类型为P2.xlarge的AWS实例运行此模型。 It is giving an error as: 它给出错误为:

Exception in thread Thread-16:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "/home/ubuntu/tensorflow/models/summarization/textsum/batch_reader.py" , line 136, in _FillInputQueue
(article, abstract) = input_gen.next()
File "/home/ubuntu/tensorflow/models/summarization/textsum/batch_reader.py", line 245, in _TextGenerator
e = example_gen.next()
File "/home/ubuntu/tensorflow/models/summarization/textsum/data.py", line 109, in ExampleGen
example_str = struct.unpack('%ds' % str_len, reader.read(str_len))[0]
MemoryError

System storage info is - 系统存储信息为-

Filesystem Size Used Avail Use% Mounted on
udev 30G 0 30G 0% /dev
tmpfs 6.0G 8.9M 6.0G 1% /run
/dev/xvda1 30G 12G 18G 39% /
tmpfs 30G 0 30G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 30G 0 30G 0% /sys/fs/cgroup
tmpfs 6.0G 0 6.0G 0% /run/user/1000

NVIDIA status- NVIDIA状态-

ubuntu@ip-172-31-28-161:~$ lspci | grep -i nvidia

00:1e.0 3D controller: NVIDIA Corporation GK210GL [Tesla K80] (rev a1) 00:1e.0 3D控制器:NVIDIA Corporation GK210GL [Tesla K80](rev a1)

What is the solution for this? 有什么解决方案?

If I replace str_len = struct.unpack('q', len_bytes)[0] with str_len = struct.unpack('Bi', len_bytes)[0] then this error disappears and new error come up as: 如果我将str_len = struct.unpack('q', len_bytes)[0]替换为str_len = struct.unpack('Bi', len_bytes)[0]则此错误消失并且出现新错误:

Exception in thread Thread-15:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "/home/mindstix/bazel/models/Summarizer/textsum/batch_reader.py", line 136, in _FillInputQueue
(article, abstract) = input_gen.next()
File "/home/mindstix/bazel/models/Summarizer/textsum/batch_reader.py", line 248, in _TextGenerator
article_text = self._GetExFeatureText(e, self._article_key)
File "/home/mindstix/bazel/models/Summarizer/textsum/batch_reader.py", line 265, in _GetExFeatureText
return ex.features.feature[key].bytes_list.value[0]
IndexError: list index (0) out of range

If I print example_str then the value displays on screen. 如果我打印example_str那么该值将显示在屏幕上。 But when I try to print ex.features.feature[key].bytes_list.value it returns blank. 但是,当我尝试打印ex.features.feature[key].bytes_list.value它返回空白。

what should be done to resolve all this? 应该怎么做才能解决所有这些问题?

This is the code steps I am following: 这是我要遵循的代码步骤:

>>> import tensorflow as tf
>>> import struct
>>>from tensorflow.core.example import example_pb2
>>> reader = open('data/training-1', 'rb')
>>> len_bytes = reader.read(8)
>>> str_len = struct.unpack('q', len_bytes)[0]
>>> str_len
2335523720558635124
>>> example_str = struct.unpack('%ds' % str_len, reader.read(str_len))[0]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
MemoryError

>>> str_len = struct.unpack('Bi', len_bytes)[0]
>>> str_len
116

>>> example_str = struct.unpack('%ds' % str_len, reader.read(str_len))[0]
>>>e = example_pb2.Example.FromString(example_str)
>>> e.features.feature['article'].bytes_list.value
<google.protobuf.pyext._message.RepeatedScalarContainer object at  0x7fc25c9325a8>

>>> e.features.feature['article'].bytes_list.value[0] 
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IndexError: list index (0) out of range

I got stacked with the same problem. 我也遇到了同样的问题。 But the reason is that I use the raw text file for test. 但是原因是我使用原始文本文件进行测试。 It is the transferred binary file should be used. 它是应该使用传输的二进制文件。 I'm not sure whether your situation is the same with me. 我不确定您的情况是否与我相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM