NPP GrabCut : ErrorOutOfMemory

Mar 11, 2013 at 11:51 PM
I am running "NPP GrabCut" in ManagedCudaSamples and it works fine when I load a small image. When I load a large image (even flower.bmp which is in the sample folder) an error occurs:
ErrorOutOfMemory: The API call failed because it was unable to allocate enough memory to perform the requested operation.

Because my graphic card has 256MB memory, I have no idea why this happens.
When I print global memory space and constant memory space, I get like below:
ctx = new CudaContext(CudaContext.GetMaxGflopsDeviceId());
ctx.GetDeviceInfo().TotalGlobalMemory => 268435456 (256MB)
ctx.GetDeviceInfo().TotalConstantMemory => 65536 (64KB)

What is the difference btw global memory and constant memory? Isn't 64KB too small?

Thanks in advance
Mar 12, 2013 at 12:49 AM

constant memory is only a small fraction of global memory that can't be written to by kernels but read access is cached. The size of 64KB is normal.
The interesting value is not the total size of memory, rather then the size of free and available memory. You can use ctx.GetFreeDeviceMemorySize() to query the value. If you're running Windows 7 or Vista with Aero enabled, it is quiet possible that not much memory is left for Cuda.

Mar 12, 2013 at 4:48 AM
Thanks for the reply Michael,

Even though not much memory is left for Cuda, loading a single 600x500 image data is not a big deal, isn't it?
If not much memory is really left for Cuda, what am I supposed to do for enlarging the space?
If there is any other possible causes, what would those be?

Mar 12, 2013 at 9:50 AM

it is not just the memory for the image that you need to allocate, you also need intermediate images and the graph to cut, which should sum up to roughly 10 times the size of your image. So even a small image, like the provided flowers, need some free space in order to work. The only way to free memory on your device is to turn off any graphics acceleration used by any application or Windows itself.
On my laptop which also has a 256 MB graphics card, already the Aero theme takes more then 200 MB, especially if more windows are open...
  • Michael