Does Matlab have any function that can calculate the required memory for a CNN?

4 次查看(过去 30 天)
Hello everyone, I'm currently doing CNN training. In my case, I'm training it with GPU.
I'm trying to find the optimum layer and optimum number of neurons for my CNN design. But sometimes, when I increase the number of layers or increase the number of neuron in FC layer, such as "fullyConnectedLayer(4096)", I encounter "Out of memory on device" error.
I understand that this error might occurs because my laptop/PC CPU+RAM or GPU memory is not enough to support my CNN structure size.
My concern is: Does Matlab have any function that can calculate the required memory for a CNN?
This can help user predict how much RAM or VRAM is needed for a CNN design.
Since we have define our layers for CNN, I hope there is a function that can save user time for manual calculation.
Hope to hear from anyone. Thank you in advance!

采纳的回答

Walter Roberson
Walter Roberson 2017-12-31
Probably not.
Although one can calculate how much memory is needed to represent a model, that would not include any temporary arrays needed during computation. In order to calculate the memory requirements, the estimator would need to know the details of the code steps and would need to know the details of when MATLAB releases temporary arrays.
For example it is easy to write something like
mask = isnan(A);
B(mask) = B(mask) + 1;
and one might "know" that the number of nan entries will be "small" -- but the mask is going to be the full size of A (always). B(mask) could be up to the full size of A, and during the addition process B(mask) is probably going to be internally duplicated in order to add 1 "in place"... so in order to accurately calculate the maximum memory requirements, one needs to analyze the entire algorithm in order to prove the maximum memory size of each step.
It might be possible in theory for CNN, but it would require that someone spend a bunch of time analyzing the code, and the tool would run the risk of being obsolete as soon as even a "small" bug fix was done to the code... so people would not generally bother to go through the trouble.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Image Data Workflows 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by