[英]Why is tensorflow consuming this much memory?
And TensorFlow is consuming more that the available memory (causing the program to crash, obviously). 而且TensorFlow消耗了更多的可用内存(显然导致程序崩溃)。
My question is : why does TensorFlow requires this much memory to run my network ? 我的问题是:为什么TensorFlow需要这么多内存才能运行我的网络? I don't understand what is taking this much space (maybe caching the data several time to optimize convolution computation ? Saving all the hidden outputs for backpropagation purpose ?).
我不明白占用了这么多空间的原因(也许是多次缓存数据以优化卷积计算?保存所有隐藏输出以用于反向传播目的?)。 And is there a way to prevent TensorFlow from consuming this much memory ?
有没有办法防止TensorFlow占用这么多的内存?
Side notes : 注意事项:
As you have mentioned: 正如您提到的:
All my convolutions are 5x5 windows, 1x1 stride, with (from 1st one to last one) 32, 64, 128 and 256 features.
我所有的卷积都是5x5窗口,1x1跨度,具有(从第一个到最后一个)32、64、128和256个功能。 I am using leaky ReLUs and 2x2 max pooling.
我正在使用泄漏的ReLU和最大2x2池。 FC layers are composed of 64 and 3 neurones.
FC层由64和3个神经元组成。
So, the memory consumption of your network goes like : 因此,您网络的内存消耗如下:
Input:
640x640x3 = 1200 (in KB) Input:
640x640x3 = 1200(以KB为单位)
C1:
636x636x32 = 12.5 MB (stride=1 worked) C1:
636x636x32 = 12.5 MB(步幅= 1有效)
P1:
635x635x32 = 12.3 MB (stride=1 worked) P1:
635x635x32 = 12.3 MB(步幅= 1有效)
C2:
631x631x64 = 24.3 MB C2:
631x631x64 = 24.3 MB
P2:
630x630x64 = 24.2 MB P2:
630x630x64 = 24.2 MB
C3:
626x626x128 = 47.83 MB C3:
626x626x128 = 47.83 MB
P3:
625x625x128 = 47.68 MB P3:
625x625x128 = 47.68 MB
C4:
621x621x256 = 94.15 MB C4:
621x621x256 = 94.15 MB
P4:
620x620x256 = 93.84 MB P4:
620x620x256 = 93.84 MB
FC1:
64 = 0.0625 KB (negligible) FC1:
64 = 0.0625 KB(可忽略)
FC2:
3 = 0.003 KB (negligible) FC2:
3 = 0.003 KB(可忽略)
Total for one image
= ~ 358 MB Total for one image
= 358 MB
For batch of 56 image
= 56 x 358 ~19.6 GB For batch of 56 image
= 56 x 358〜19.6 GB
That's why your network does not run on 6 GB
. 这就是为什么您的网络无法在
6 GB
上运行的原因。 Try with some higher stride
or lower sized image
to adjust it into 6 GB
space. 尝试使用
higher stride
或lower sized image
将其调整为6 GB
空间。 And it should work. 它应该工作。
You can refer this to better understand memory consumption calculation. 您可以参考此以更好地了解内存消耗的计算。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.