Matlab: Error using parallel_function: Out of Memory

940 Views Asked by At

I am using Matlab R2011b version on Windows 7 64 bit, Core i7 CPU with 8 GB RAM. I am running Approximate Nearest Neighbor algorithm called the Locality Sensitive Hashing using Matlabpool. Upon starting Matlab pool, I get the output

Starting matlabpool using the 'local' configuration ... connected to 4 labs.

When the control reaches the for loop, Matlab throws errro

Error using parallel_function (line 598)

Out of memory. Type HELP MEMORY for your options.

Error stack:
remoteParallelFunction.m at 29

Error in Evaluate (line 19)
parfor i=1:query_num

I have no clue how to solve this problem. Please help. Thank you

1

There are 1 best solutions below

2
On BEST ANSWER

That is because the parfor requires a lot more memory.

All the workers/labs in a parfor loop are independent so each of them needs his amount of memory. Also, there is overhead involved due to the fact that the pool must spread and collect data from/to the workers.

Try using a regular for or open a pool with 2 workers instead of 4.

Also, it depends on how optimized your some_function() is: try using as few variables as possible.