How to use parfor-loop or parallel computation on a cluster?

3 Ansichten (letzte 30 Tage)
Dear Matlabers,
I am trying to use parfor-loop on a cluster, therefore I wrote a script to test. the script-1 run successfully, but consumed more time than on my own pc, it seems that it only use one processor; therefore, I invoked matlabpool in the script-2, but this script even doesn't run on the cluster and gave error:
"To get started, type one of these: helpwin, helpdesk, or demo.For product information, visit www.mathworks.com.
Error using matlabpool>iVerifyJava (line 163) matlabpool is not supported because: Java is not currently available.
Error in matlabpool (line 122) iVerifyJava(); Error in TestPara (line 16)matlabpool open;"
Now, my question is how can I change my script to use parfor-loop on a cluster?
thank you in advance!
George
% script-1 parfor-loop
itr = 1E8;
tic;
parfor i = 1:itr
tx (i)= 2*i;
end
t = toc;
fileID = fopen('timeNormal.txt','w');
fprintf(fileID,' Time 1 is: %6.2f seconds \n',t);
fclose(fileID);
% script-2 matlabpool
matlabpool open;
tic,
parfor i = 1:itr
tx (i)= 2*i;
end
t = toc;
fileID = fopen('time2.txt','w');
fprintf(fileID,' Time 2 is: %6.2f seconds \n',t);
fclose(fileID);
matlabpool close

Akzeptierte Antwort

Edric Ellis
Edric Ellis am 7 Aug. 2012
You should send 'script-1' as a batch script for execution on your cluster with an open MATLABPOOL, like this:
j = batch('script_2', 'Matlabpool', 4);
This will run automatically configure an open matlabpool on the cluster of size 4. This blog entry shows you the stages you go through from running scripts on your desktop to running them with PARFOR on a cluster: http://blogs.mathworks.com/loren/2012/04/20/running-scripts-on-a-cluster-using-the-batch-command-in-parallel-computing-toolbox/

Weitere Antworten (1)

George
George am 7 Aug. 2012
Bearbeitet: George am 7 Aug. 2012
But when I use batch, I couldn't find the output file.
however, it works on my own computer. so where is wrong?
here, I firstly wrote a script1.m
itr = 1E5;
tic;
parfor i = 1:itr
tx (i)= 2*i;
end
t = toc;
%
fileID = fopen('Result.txt','w');
fprintf(fileID,' Time 1 is: %6.2f seconds \n',t);
fprintf(fileID,' Max: %6.2f \n',max(tx));
fclose(fileID);
and then I wrote another batch script to run the script1.m
job = batch('script1', 'matlabpool', 5);
delete(job)
again, thank you.
kind regards,
George

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by