0

I am trying to train a CNN model using 3 classes and around 500 images in each class. The size of the images are [965*995*1]. When I run the code I get an error saying "Maximum variable size allowed on the device is exceeded."

The model gives an error "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)"when I resize the images to [128 *128].

It runs fine when I resize the images to [64*64].

How can I go around this issue?

Note: The system has 16GB of RAM.

1 Answer 1

1

First, you are probably limited by the size of RAM of your GPU and not your CPU.

So if you need to process large images set ConvNet to run on the CPU instead of the GPU.

In general in the latest MATLAB releases MathWorks added the option to define a limitation on Variable size as a function of the RAM.
You can access it by going:

Preferences -> Workspace

You will there the following:

MATLAB Preferences -> Workspace Settings

You'll have the option to limit the size of variables according to your RAM.
In your case setting it to 100% means the largest (CPU) variable is 16GB.
If you uncheck the limit MATLAB will use the Page File for larger size variables.
Yet this is not recommended as you will be limited by the speed of your Hard Drive.

You can read more at Resolve "Out of Memory" Errors.

Sign up to request clarification or add additional context in comments.

2 Comments

The array size limit was already at 100%. And running training networks on CPU and not GPU is only possible in Matlab 2017a, right? Or do you know any other way to do that?
The scaling is relative to the RAM in your computer (16 GB as you pointed). Yet for GPU Arrays you're limited to the RAM of your GPU (You didn't specify which one you have). The above screen goes back to R2015a I think. You have 4 options: 1. Work on CPU and remove limitation (Bad choice in my opinion). 2. Work on CPU and limit the net parameters to match your memory limitations. 3. Work on GPU and limit net to the GPU memory. 4. Upgrade hardware to your net needs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.