필터 지우기
필터 지우기

GPU Out of memory on device.

조회 수: 44 (최근 30일)
caesar
caesar 2018년 3월 16일
댓글: Thyagharajan K K 2021년 11월 28일
I am using the neural network toolbox for deep learning and I have this chronical problem when I am doing a classification. My DNN model has trained already and I keep receiving the same error during classification despite the fact that I used an HPC (cluster) that has Nvidia GeForce 1080, and my machine that has GeForce 1080Ti. the error is :
Error using nnet.internal.cnngpu.convolveForward2D 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.Convolution2DGPUStrategy/forward (line 14)
Error in nnet.internal.cnn.layer.Convolution2D/doForward (line 332)
Error in nnet.internal.cnn.layer.Convolution2D/forwardNormal (line 278)
Error in nnet.internal.cnn.layer.Convolution2D/predict (line 124)
Error in nnet.internal.cnn.DAGNetwork/forwardPropagationWithPredict (line 236)
Error in nnet.internal.cnn.DAGNetwork/predict (line 317)
Error in DAGNetwork/predict (line 426)
Error in DAGNetwork/classify (line 490)
Error in Guisti_test_script (line 56)
parallel:gpu:array:OOM
Has anyone faced the same problem before?
ps: my test data contains 15000 images.
  댓글 수: 1
Thyagharajan K K
Thyagharajan K K 2021년 11월 28일
I had a similar problem. The main reason is due to the large number of learnable parameters. You can reduce the number of nodes in the fully connected network or you can reduce the size of the layer available just before the fully connected layer by incresing the stride value or you can reduce both.

댓글을 달려면 로그인하십시오.

채택된 답변

Joss Knight
Joss Knight 2018년 3월 17일
Reduce the 'MiniBatchSize' option to classify.
  댓글 수: 2
caesar
caesar 2018년 3월 17일
well, the model I am trying to use has been already trained so how can I reduce the miniBatchsize? should I retrain the model on reduced MiniBatchSize in order to be able to do classification?

댓글을 달려면 로그인하십시오.

추가 답변 (3개)

Khalid Labib
Khalid Labib 2020년 2월 19일
편집: Khalid Labib 2020년 5월 13일
In "Single Image Super-Resolution Using Deep Learning" MatLab demonstration:
I tried clear my gpu memory ( gpuDevice(1) ) after each iteration and changed MiniBatchSize to 1 in "superResolutionMetrics" helper function, as shown in the following line, but they did not work (error: gpu out of memory):
residualImage =activations(net, Iy, 41, 'MiniBatchSize', 1);
1) To solve this problem you might use CPU instead:
residualImage =activations(net, Iy, 41, 'ExecutionEnvironment', 'cpu');
I think this problem is caused by the high resolution of the test images, e.g. the second image "car2.jpg", which is 3504 x 2336.
2) A better solution is to use GPU for low resolution images, and CPU for high resoultion images by replacing "residualImage =activations(net, Iy, 41)" with:
sx=size(I);
if sx(1)>1000 || sx(2)>1000 %try lower values if it does not work e.g: if sx(1)>500 || sx(2)>500
residualImage =activations(net, Iy, 41, 'ExecutionEnvironment', 'cpu');
else
residualImage =activations(net, Iy, 41);
end
3) The most efficient solution is to divide the image into smaller images (non-overlapping blocks or tiles), such that each small image has a size of 1024 or less in any of its dimension based on your GPU. So, you can use GPU for each of these small images without errors.
Then, apply your CNN on these small images using GPU. After that, you can combine the small images to form the size of original image.
  댓글 수: 1
Rui Ma
Rui Ma 2020년 4월 22일
편집: Rui Ma 2020년 4월 22일
Thanks! It works! Although a little bit slow

댓글을 달려면 로그인하십시오.


marie chevalier
marie chevalier 2019년 6월 4일
편집: marie chevalier 2019년 6월 4일
Hi,
I have a similar issue here, and the link given by Joss doesn't really help me to understand how to fix it.
I am working on the "Single Image Super-Resolution Using Deep Learning" MatLab demonstration.
I would like to use the pretrained network on my own images.
I get a similar error message when arriving at the line:
Iresidual = activations(net,Iy_bicubic,41);
I tried using the command line gpuDevice(1) and it didn't do anything.
I also tried changing the MiniBatchSize to 32 instead of the default 128 and got the same error.
Does anyone understand how to fix this problem?
  댓글 수: 3
marie chevalier
marie chevalier 2019년 6월 26일
It still doesn't work. I'm afraid this is due to something else.
I'm out of ideas at the moment, I did a little cleanup around my computer just to be safe but it didn't change much.
I'll try re-downloading the example again, maybe I changed something in it without noticing.
Akash Tadwai
Akash Tadwai 2019년 12월 17일
@Joss Knight, It still doesn't work in my case. I was training alex net with a mini batch size of 1 but still MATLAB is giving the same error.
Alexnet

댓글을 달려면 로그인하십시오.


Alvaro Lopez Anaya
Alvaro Lopez Anaya 2019년 11월 7일
In my case, I had similar problems, despite of the fact that I have a gtx1080Ti.
As Joss said, reducing the MiniBatchSize solved my problem. It's all about the training options.

카테고리

Help CenterFile Exchange에서 Parallel and Cloud에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by