【发布时间】:2018-05-30 14:40:27
【问题描述】:
这是我的错误:
OOM when allocating tensor of shape [7,7,512,4096] and type float
[[Node: W6/Adam/Initializer/zeros = Const[dtype=DT_FLOAT, value=Tensor<type: float shape: [7,7,512,4096] values: [[[0 0 0]]]...>, _device="/job:localhost/replica:0/task:0/device:GPU:0"]()]]
在回溯中我可以看到它是由这一行引起的:
sess.run(tf.global_variables_initializer())
所有参数组合使用大约 1.5Gb 的内存。我有 4 Gb 的可用内存。
我已经试过了,没有成功:
config.gpu_options.allocator_type = 'BFC'
config.gpu_options.per_process_gpu_memory_fraction = 0.40
config.gpu_options.allow_growth = True
我该如何解决?
编辑:
我是如何计算已用内存量的?
var_sizes = [np.product(list(map(int, v.shape))) * v.dtype.size
for v in tf.get_collection(tf.GraphKeys.GLOBAL_VARIABLES)]
print(sum(var_sizes) / (1024 ** 2), 'MB')
【问题讨论】:
-
我猜你实际上需要超过 1.5Gb。你是怎么得到这个号码的?
-
我添加了信息。不过应该不是问题。
标签: tensorflow