YoloV4 - Out of memory

12 views (last 30 days)
Thomas Cimiega
Thomas Cimiega on 13 Dec 2022
Commented: Thomas Cimiega on 21 Dec 2022
I am trying to run YoloV4 example object detection using yolov4 deep learning on my local computer (GeForce GTX 1060, 16Gb RAM, Windows) using the local .mlx script and get the following error in line 95:
detectionResults = detect(detector,testData);
Error using dlnetwork/predict
Layer 'mish_2': Invalid input data. Error using the predict function in layer nnet.cnn.layer.FunctionLayer. The function
threw an error and could not be executed.
Error in yolov4ObjectDetector>iPredictActivations (line 1152)
[features{:}] = predict(network, dlX, 'Acceleration',acceleration);
Error in yolov4ObjectDetector/predict (line 517)
features = iPredictActivations(network, imgBatch, anchorBoxes, predictParams.Acceleration);
Error in vision.internal.detector.ObjectDetector/performDetect (line 72)
features = this.predict(Ipreprocessed, params);
Error in yolov4ObjectDetector/detect (line 404)
[varargout{1:nargout}] = performDetect(detector, I, params);
Caused by:
Error using gpuArray/max
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 dlarray/max (line 96)
zdata = max(matlab.lang.internal.move(xdata), matlab.lang.internal.move(ydata), varargin{:});
Error in vision.cnn.mish (line 22)
Z1 = max(X,0) + log(1 + exp(-abs(X)));
Error in nnet.cnn.layer.FunctionLayer/predict (line 61)
[varargout{1:layer.NumOutputs}] = feval(layer.PredictFcn, varargin{:});
Of course I researched and tried to decrease the minibatch size to 1 (line 75) or to reset the gpu device according to [1]. I also tried to run this code on different devices like a gpu server with 4 TITAN RTX GPUs, 1TB RAM and Arch Linux. Still the same error.
Do I miss some other settings that could cause this error?

Accepted Answer

Joss Knight
Joss Knight on 17 Dec 2022
Generally the best solution here is to reduce the size of the input data.
Still, these object detector networks do seem to be unusually large. You could try a smaller one (yolov3tiny?) or you could see if you get good enough performance for your purposes on the CPU.
You could also try the Acceleration="none" option if available to you, since older versions of MATLAB had an issue that would cause memory usage to spike during optimization.
  1 Comment
Thomas Cimiega
Thomas Cimiega on 21 Dec 2022
thank you, reducing the size of the input data actually works fine!

Sign in to comment.

More Answers (0)

Categories

Find more on Deep Learning with GPU Coder in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!