Trying to get executable to use other computer's multiple cores with matlabpool, but getting error

Using Matlab 2011a on a winXP 32 bit machine with 2 cores, I have a program I turned into an executable using Matlab Compiler that I want to run on another windows7, 64 bit, quad core computer. Here's the simplified version...
clear all
close all
matlabpool open 2
currdir = cd;
imDir = [cd '\0625_15\'];
parfor ii = 1:8
%%process code %%
end
y = toc;
matlabpool close
I've installed the MRC on the new machine and have also tried, with success, using 1 processor in the code (ie. not using matlabpool). Using 1 core in the executable runs fine on the new machine.
When the executable runs on the newer machine with "matlabpool open 2", I get an error saying...
Starting matlabpool using the 'localconfig-hyperthread' configuration ... connected to 2 labs
??? The class "distcomp.remoteparfor" is undefined
How can I get the code to run and take advantage of the multiple cores of the newer machine? Do I need to include the local scheduler configuration file? If so, how do I do this exactly?

 Accepted Answer

Solved the problem. Turns out I needed to make my code a function before compiling it into an executable. I simply added
function testcode
at the top of my code.
This got rid of the
Error in ==> parallel_function at 430
Hope this helps out.

1 Comment

Dang, I never think to look for this because I assume people already know that. The compiler does not handle scripts.

Sign in to comment.

More Answers (2)

Yes, you should be using the local scheduler, and there are some other steps you should look at. Please see http://www.mathworks.com/matlabcentral/answers/26472-how-to-define-local-matlabpool-size-at-runtime-for-parallel-computing-toolbox-use-in-compiled-matl

4 Comments

I created a new configuration named compiled.mat where the "Number of Workers Available to the scheduler = 4" to take advantage of the 4 cores on the new machine.
I ran the following command...
final.exe -mcruserdata ParallelConfigurationFile:compiled.mat
This still unfortunately gave me the same error.
Any ideas as to why?
The new configuration I created (compiled.mat), I realize now, is a local configuration on the old machine. So I'm guessing that is why is still doesn't work when run on the new machine.
The link you provided assumes the target machines the executable is to run on is connected to a cluster. This is different than my situation where I just want to use the local cores on the new machine. The example in your link shows that they created a new jobmanager configuration to access a cluster, but this obviously won't work for me.
You should be changing the "matlabpool open 2" to "matlabpool" or "matlabpool open".
Note also in the documentation "Note A compiled application should set mcruserdata ParallelConfigurationFile before calling any Parallel Computing Toolbox™ code."
It appears to me from the discussion in that other thread and the documentation pointed to, that the cluster vs non-cluster is not important for this purpose.
Regrettably, standing on the downtown corners, holding out a hat, and asking, "Spare Parallel Computing Toolbox?" has only netted me two bus tickets, a used comb, half a submarine sandwich, and 43 cents in change, so I cannot test these matters myself.
Changing to just matlabpool open helped, but I am now getting another error. See next post...

Sign in to comment.

When I run my executable on the machine with matlab, I am getting the following error...
--- Starting matlabpool using the 'local' configuration ... connected to 2 labs. ??? The class "distcomp.remoteparfor" is undefined. Perhaps Java is not running.
Error in ==> parallel_function at 430
Error in ==> testcode at 11
MATLAB:subscripting:undefinedClass
I get the same error on the machine without matlab as well. Here is my code. Compiled.mat is the local parallel configuration...
clear all
close all
% Set the Parallel Configuration file:
if(isdeployed)
matfile = 'compiled.mat';
setmcruserdata('ParallelConfigurationFile',matfile);
end
matlabpool open
parfor ii = 1:8
disp(ii)
end
matlabpool close
It seems to be having an issue with the parfor line. I've checked the following thread below for answers, but still no luck. Can anyone help me out? http://www.mathworks.com/matlabcentral/answers/19169-parfor-error-after-compiled

Categories

Asked:

on 20 Jan 2012

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!