MATLAB Error: Maximum Variable Size Allowed on the Device Is Exceeded

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.


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首选项 - >工作区设置

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.

链接地址: http://www.djcxy.com/p/29282.html

上一篇: 如何使用jQuery获取选择的所有选项?

下一篇: MATLAB错误:超出设备允许的最大变量大小