Out of memory error

I am trainning Unet. I have 7500 images and their masks. The size of individual image and mask is (512,180). I have divided the data for training and testing in ratio of 0.9:0.1. My training goes fine but i get Out of memory error after it. The network then doesnot perform any testing. Kindly tell me the solution
The error is given as.
Out of memory on device. To view more detail about available memory on the GPU, use 'gpuDevice()'. If the problem persists, reset the GPU by
calling 'gpuDevice(1)'.
Error in nnet.internal.cnn.layer.util.BatchNormalizationGPUStrategy/forwardPredict (line 14)
Z = nnet.internal.cnngpu.batchNormalizationForwardPredict(X, beta, gamma, epsilon, inputMean, inputVar, channelDim);
Error in nnet.internal.cnn.layer.BatchNormalization/predict (line 159)
Z = this.ExecutionStrategy.forwardPredict( ...
Error in nnet.internal.cnn.DAGNetwork/activations (line 571)
outputActivations = thisLayer.predict(XForThisLayer);
Error in DAGNetwork/calculateActivations (line 86)
YBatch = predictNetwork.activations({X}, layerIndex, layerOutputIndex);
Error in DAGNetwork/activations (line 138)
Y = this.calculateActivations(X, layerIndex, layerOutputIndex, varargin{:});
Error in semanticseg>iClassifyImagePixels (line 447)
allScores = activations(net, X, name, ...
Error in semanticseg>iProcessImageDatastoreSerially (line 663)
L = iClassifyImagePixels(X, net, params);
Error in semanticseg (line 211)
filenames = iProcessImageDatastoreSerially(imds, net, params);
Error in Step5NeuralNetwork (line 90)
pxdsResults = semanticseg(imdsTest,net,'WriteLocation',tempdir,'Verbose',false);

4 Comments

Have you tried reducing the memory pressure? The normal way to do this in the semanticseg function would be to reduce the MiniBatchSize option.
Thanks for your help ! It worked
How do you change the miniBatchSize of a pretrained network? Is there a function? If so, how is it written and where should it be placed in the code?
Thank you!
You read the documentation and see that for a DAGNetwork, the predict, classify and activations functions have a MiniBatchSize option. Is that what you're using?

Sign in to comment.

Answers (0)

Asked:

on 31 Dec 2019

Commented:

on 12 Jun 2022

Community Treasure Hunt

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

Start Hunting!