error with parfor and big matrices
Show older comments
I have a code which uses large multidimensional matrices inside a parfor loop. However, for the size of matrices I need to use, I get the following error (for smaller matrices there is no problem):
Warning: Error caught during construction of remote parfor code.
The parfor construct will now be run locally rather than
on the remote matlabpool. The most likely cause of this is
an inability to send over input arguments because of a
serialization error. The error report from the caught error is:
Error using distcompserialize
Error during serialization
Error in distcomp.remoteparfor (line 36)
obj.SerializedInitData =
distcompMakeByteBufferHandle(distcompserialize(varargin));
Error in parallel_function (line 437)
P = distcomp.remoteparfor(W, @make_channel, parfor_C);
> In parallel_function at 450
If I run the same code with for instead of parfor, the program runs through without any error. My code looks like this (a simple example which throws this warning):
matlabpool open
BigMat = randn(30,30,30,30,30,30);
parfor i = 1:20
CopyOfBigMat = BigMat;
end
matlabpool close
Also, I tried to run it with only one worker, but I still get the same error. So I don't think that the problem is caused by not enough physical memory (I run 64bit R2012b with 16GB RAM).
Since my problem is similar to the one posted here
I also tried to use the WorkerObjWrapper function which was suggested in that post. My code then looks like this:
matlabpool open
BigMat = randn(30,30,30,30,30,30);
w = WorkerObjWrapper(BigMat);
parfor i = 1:20
data = w.Value; %#ok<*PFBNS>
CopyOfBigMat = data;
end
matlabpool close
but this actually throws another error:
Error using distcompserialize
Error during serialization
Error in spmdlang.RemoteSpmdExecutor/initiateComputation (line 82)
fcns = distcompMakeByteBufferHandle( ...
Error in spmdlang.spmd_feval_impl (line 14)
blockExecutor.initiateComputation();
Error in spmd_feval (line 8)
spmdlang.spmd_feval_impl( varargin{:} );
Error in WorkerObjWrapper>(spmd) (line 155)
spmd
Error in WorkerObjWrapper/workerInit (line 155)
spmd
Error in WorkerObjWrapper (line 97)
WorkerObjWrapper.workerInit( tmpId, ctor, args, dtor );
Does anyone know what causes the error during parfor? And has anyone found a solution/workaround for it? Thanks a lot!
Accepted Answer
More Answers (1)
Edric Ellis
on 1 May 2013
0 votes
Please note that this problem is fixed in R2013a.
4 Comments
Kathrin
on 6 May 2013
Edric Ellis
on 7 May 2013
Hi Kathrin - for systems where the MATLAB client and matlabpool workers are all 64-bit, we can send data to and from PARFOR loops up to the limit of the amount of RAM on your system.
Kathrin
on 7 May 2013
Aya Ibrahim
on 22 Jul 2016
Hi Edric, I am using Matlab R2013a and I still have this problem! is there something special that we should do to make that work in R2013a?!
Categories
Find more on Parallel for-Loops (parfor) in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!