How to use parfor-loop or parallel computation on a cluster?
1 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
Edric Ellis
2012-8-7
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/
更多回答(1 个)
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!