- I have a simple CNN (4 conv-pool-lrelu layers and 2 fully connected ones).
- I am only using TensorFlow on CPU (no gpu).
- I have ~6GB of available memory.
- My batches are composed of 56 images of 640x640 pixels ( < 100 MB ).
And TensorFlow is consuming more that the available memory (causing the program to crash, obviously).
My question is : why does TensorFlow requires this much memory to run my network ? 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 ?
Side notes :
- I cannot reduce the size of the batch, I am trying to make some Multiple Instance Learning, so I need to compute all my patches in one run.
- I am using a AdamOptimizer
- All my convolutions are 5x5 windows, 1x1 stride, with (from 1st one to last one) 32, 64, 128 and 256 features. I am using leaky ReLUs and 2x2 max pooling. FC layers are composed of 64 and 3 neurones.
- Using Ubuntu 16.4 / Python 3.6.4 / TensorFlow 1.6.0