tensorflow conv2d的内存消耗有解释吗? [英] tensorflow conv2d memory consumption explain?

查看:163
本文介绍了tensorflow conv2d的内存消耗有解释吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

output = tf.nn.conv2d(input, weights, strides = [1,3,3,1], padding = 'VALID')

我的input的形状为200x225x225x1,weights的形状为15x15x1x64.因此,由于(225-15)/3 + 1 = 71

My input has shape 200x225x225x1, weights is 15x15x1x64. Hence, the output has shape 200x71x71x64 since (225-15)/3 + 1 = 71

Tensorboard显示此操作总共消耗768MB(请参见下图).假设考虑了输入(38.6MB),权重(0.06MB)和输出(246.2MB)的大小,则总内存消耗不应超过300MB.那么其余的内存消耗来自何处?

Tensorboard shows that this operation consumes totally 768MB (see pic below). Assuming it takes into account the size of input (38.6MB), weights (0.06MB) and output (246.2MB) the total memory consumption should not exceed 300MB. So where does the rest of the memory consumption come from?

推荐答案

尽管我无法根据提供的信息来重现您的图形和值,但是由于在执行过程中实现了中间值,您可能会看到更多的内存使用情况Conv2D的计算.检测也可能不正确. (例如,不会导致生成Tensor内存副本的重塑操作最终会导致TF Node Stats工具中的内存使用情况"重复.)如果没有可重现的测试用例,就很难多说了.如果您确实认为这是TensorFlow中的错误,请在Github上提出问题!

Although I'm not able to reproduce your graph and values based on information provided, it's possible that you're seeing additional memory usage due to intermediary values materialized during the computation of Conv2D. It's also possible that the instrumentation is incorrect. (e.g. reshape operations that do not result in a copy of Tensor memory end up duplicating the "memory usage" in the TF Node Stats instrumentation.) Without a reproducible test case, it's hard to say more. If you do feel like this is a bug in TensorFlow, please do raise an issue on Github!

这篇关于tensorflow conv2d的内存消耗有解释吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆