Out of memory error in matlab

1 view (last 30 days)
Suhani Agarwal
Suhani Agarwal on 15 Feb 2018
Commented: Walter Roberson on 8 Jun 2020
trainingFeatures = activations(net, trainingSet, featureLayer, ...
'MiniBatchSize', 10, 'OutputAs', 'columns');
trainingSet is an imagestore containing 3 million entries.
net is a pretrained alexnet.
featureLayer we are using is fc7 .
This is the line which I am using, But I am getting error messege
Error using zeros
Out of memory. Type HELP MEMORY for your options.
Error in SeriesNetwork/activations (line 365)
Y = precision.cast( zeros(sz) );
I am using Matlab 2017a, GPU enabled & RAM of 16GB. I had done below mention things to resolve problem but it doesn't get resolved
In Matlab, Home-> Preference->General->JavaHeapMemory->(Then increase the size)

Answers (2)

Joss Knight
Joss Knight on 15 Feb 2018
Clearly you can't store the activations for your entire dataset in memory. fc7 of AlexNet has 4096 single precision outputs. That's 16K. So 3 million of those takes 45 GB.
Try computing the activations in chunks.

Javier Pinzón
Javier Pinzón on 8 Mar 2018
Hello Suhani,
That happens when you GPU can store all the data of one iteration or the data of the activations, so it do not let you continue with the process.
The best way to know what is happening in your GPU consumption, is with this:
- I recommend you to install a third party program called AfterBurner, it let you see how many memory are you using in your GPU.
- If your GPU is about 2 GB space, so it probably is getting out of memory because of it capacity, so you can check if the highest value of memory is reached with the third party software at the time you run your program.
Hope it may help you
Regards,
Javier
  1 Comment
Walter Roberson
Walter Roberson on 8 Jun 2020
If I recall, alexnet uses GPU by default. GPUs just do not have a lot of memory (and the situation is worse on MS Windows, which reserves a large chunk of memory for communicating with the GPU.)
Switching to Python will not increase the amount of memory that is available on your GPUs.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!