Dedicated GPU Memory Usage - Permanently increases every time code is run
Mostrar comentarios más antiguos
Every time I run my code, the dedicated GPU Memory Usage permanently increases. I am using a pretrained neural network called detectTextCRAFT which is built into MATLAB. This error only recently started happening and I have been developing this code for multiple weeks so it is a new problem. Initially I would get this error:
Error using dlnetwork/predict
Layer 'codegen_1': Invalid input data. Layer 'Resize_54_new': Invalid input data. Error using 'predict' in layer nnet.cnn.layer.Resize2DLayer. The function threw an error and could not be executed.
Error in detectTextCRAFT (line 141)
networkOutput = predict(craftNet,Ipreprocessed,'Acceleration',params.Acceleration);
Error in Test7 (line 4)
bbox = detectTextCRAFT(I,CharacterThreshold=0.4);
Caused by:
Error using gpuArray/interp1
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 deep.internal.recording.operations.Interp1Op/forward (line 33)
vq = interp1(x,v,xq,op.Method,extrap);
Error in deep.internal.recording.RecordingArray/interp1 (line 7)
vq = recordNary(x,v,xq,extrap,1,op);
Error in dlarray/interp1 (line 76)
dataVq = interp1(dataX, dataV, dataXq, method, dataExtrap);
Error in images.dlresize.internal.interpSpatialDims>interpAlongSpatialDim (line 52)
out = interp1(1:inputDimSize,in,queryPoints',method);
Error in images.dlresize.internal.interpSpatialDims (line 12)
out = interpAlongSpatialDim(out,spatialDim,start,stride,stop,...
Error in nnet.cnn.layer.Resize2DLayer/predict (line 144)
Z = images.dlresize.internal.interpSpatialDims(X,start,stop,stride,layer.DlresizeMethodName,layer.NearestRoundingMode,scale,inputSpatialDimSize);
Then I used gpuDevice(1) to reset the GPU and then I got this error,
Error using nnet.internal.cnn.dlnetwork/predict
Layer 'Conv_0, Relu_1': Invalid input data. The data no longer exists on the device.
Error in nnet.internal.cnn.dlnetwork/DefaultOptimizationStrategy/propagate (line 78)
[varargout{1:nargout}] = inferenceMethod(net, X, layerIndices, layerOutputIndices);
Error in nnet.internal.cnn.dlnetwork/DefaultOptimizationStrategy/predict (line 28)
[varargout{1:nargout}] = propagate(strategy, net, X, ...
Error in dlnetwork/predict (line 661)
[varargout{1:nargout}] = strategy.predict(net.PrivateNetwork, x, layerIndices, layerOutputIndices);
Error in detectTextCRAFT (line 141)
networkOutput = predict(craftNet,Ipreprocessed,'Acceleration',params.Acceleration);
Error in Test7 (line 4)
bbox = detectTextCRAFT(I,CharacterThreshold=0.4);
Then I redownloaded the detectTextCRAFT add-on and now the current problem has been that the dedicated GPU memory usage permanently increases every time code is run. On top of that, the OCR function that detects the words has been outputting much worse that it is supposed to with lots of empty outputs and inaccuracies everywhere. It used to work much better.
Thank you!
Respuesta aceptada
Más respuestas (1)
Joss Knight
el 12 de Jun. de 2022
1 voto
This error means you ran out of GPU memory. I can't reproduce any sort of memory leak in R2022a. It's possible that you are permanently storing some of your results in a growing array? If you are running R2022a you can use whos to see how much GPU memory your workspace variables are using, to make sure they are not growing in size each time you run your code. Alternatively, call clear before running your code again, to see if the memory leak goes away.
1 comentario
Anay Naik
el 14 de Jun. de 2022
Categorías
Más información sobre GPU Computing en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!