如何拥有 tf.zero 形状的大矩阵
How to have a large matrix of tf.zero shape
print("sequences",len(sequences))
print("seq_length",(seq_length))
print("vocab size",(vocab_size))
X = tf.zeros((len(sequences), seq_length, vocab_size), dtype=tf.bool)
y = tf.zeros((len(sequences), vocab_size), dtype=tf.bool)
输出
sequences 30373553
seq_length 30
vocab size 1290174
ResourceExhaustedError Traceback (most recent call last)
<ipython-input-35-1bd9b1544ba0> in <module>()
2 print("seq_length",(seq_length))
3 print("vocab size",(vocab_size))
----> 4 X = tf.zeros((len(sequences), seq_length, vocab_size), dtype=tf.bool)
5 y = tf.zeros((len(sequences), vocab_size), dtype=tf.bool)
6
3 frames
/usr/local/lib/python3.6/dist-packages/six.py in raise_from(value, from_value)
ResourceExhaustedError: OOM when allocating tensor with shape[30373553,30,1290174] and type bool on /job:localhost/replica:0/task:0/device:CPU:0 by allocator cpu [Op:Fill] name: zeros/
正在处理 tensorflow 2.0
我想制作一个形状为 [30373553,30,1290174]
的零矩阵
在 TensorFlow 1.5 上运行相同的代码时没有这样的错误,但在 TensorFlow 2.0 上运行时出现此错误
假设每个 bool
元素使用 1 个字节的内存,您的形状 [30373553, 30, 1290174]
的张量将需要大约 1200 TB 的内存才能实现。那是很多内存...
我猜这在 TensorFlow 1.5 中没有出错,因为旧的延迟执行范例,你可以毫无问题地调用 tf.zeros([30373553, 30, 1290174])
,因为调用返回的符号张量不会'在您对包含张量的 tf.Graph 调用 tf.Session.run()
之前,它实际上不会分配到内存中。然而,在 TensorFlow 2.0 中,eager execution 将在调用后立即执行内存分配。
print("sequences",len(sequences))
print("seq_length",(seq_length))
print("vocab size",(vocab_size))
X = tf.zeros((len(sequences), seq_length, vocab_size), dtype=tf.bool)
y = tf.zeros((len(sequences), vocab_size), dtype=tf.bool)
输出
sequences 30373553
seq_length 30
vocab size 1290174
ResourceExhaustedError Traceback (most recent call last)
<ipython-input-35-1bd9b1544ba0> in <module>()
2 print("seq_length",(seq_length))
3 print("vocab size",(vocab_size))
----> 4 X = tf.zeros((len(sequences), seq_length, vocab_size), dtype=tf.bool)
5 y = tf.zeros((len(sequences), vocab_size), dtype=tf.bool)
6
3 frames
/usr/local/lib/python3.6/dist-packages/six.py in raise_from(value, from_value)
ResourceExhaustedError: OOM when allocating tensor with shape[30373553,30,1290174] and type bool on /job:localhost/replica:0/task:0/device:CPU:0 by allocator cpu [Op:Fill] name: zeros/
正在处理 tensorflow 2.0
我想制作一个形状为 [30373553,30,1290174]
的零矩阵
在 TensorFlow 1.5 上运行相同的代码时没有这样的错误,但在 TensorFlow 2.0 上运行时出现此错误
假设每个 bool
元素使用 1 个字节的内存,您的形状 [30373553, 30, 1290174]
的张量将需要大约 1200 TB 的内存才能实现。那是很多内存...
我猜这在 TensorFlow 1.5 中没有出错,因为旧的延迟执行范例,你可以毫无问题地调用 tf.zeros([30373553, 30, 1290174])
,因为调用返回的符号张量不会'在您对包含张量的 tf.Graph 调用 tf.Session.run()
之前,它实际上不会分配到内存中。然而,在 TensorFlow 2.0 中,eager execution 将在调用后立即执行内存分配。