[心得] Matlab Distributed Computing
測試環境
Computer1: P4 3.4G, 1G RAM Win XP SP2, Matlab 2006a
computer name: QQMOU
Job-Manager name: QQMOU_jobmanager
Worker name: QQMOU_worker
Computer2: P4 2.8G, 1G RAM Win XP SP2, Matlab 2006a
computer name: mychat-7b73b358
Worker name: QQMOU_worker1
測試結果
Dist-comp: 131.18 sec
Computer1: 226.42 sec
結論
利用 dist-computing 確實可以加速
然而 dist-computing 協定本身的 overhead 頗重
但是當運算量極大時, protocol 的 overhead 可以忽略
以上結果顯示, 運用兩台速度相近的電腦計算, 得到 42% 的加速
----
建構 cluster
1. 設定 MDCE server
$MATLAB\toolbox\distcomp\bin\win32\mdce install
$MATLAB\toolbox\distcomp\bin\win32\mdce start
2. 設定 job-manager (僅需一台)
$MATLAB\toolbox\distcomp\bin\win32\startjobmanager.bat
-name QQMOU_jobmanager -clean -v
ps. 我的 job manager 裝在 computer 1
QQMOU_jobmanager 是名字, 可以自己取
3. 設定 worker (在每一台都要設定)
Computer 1:
$MATLAB\toolbox\distcomp\bin\win32\startworker.bat
-name QQMOU_worker -jobmanager QQMOU_jobmanager
-jobmanagerhost QQMOU -clean -v
Computer 2:
$MATLAB\toolbox\distcomp\bin\win32\startworker.bat
-name QQMOU_worker1 -jobmanager QQMOU_jobmanager
-jobmanagerhost QQMOU -clean -v
4. 檢查設定 (可以在每一個 node 上做)
$MATLAB\toolbox\distcomp\bin\win32\nodestatus.bat
-infolevel 2
----
分別用 dist-computing 和 單機執行以下函數:
[fun.m]
function x = fun(times)
x = 0;
for i=1:times
x = x + sum(randn(1,10000));
x = x / 10000;
end
單機執行
tic % 啟動碼表
fun(30000);
fun(30000);
fun(30000);
fun(30000);
fun(30000);
fun(30000);
fun(30000);
fun(30000);
fun(30000);
fun(30000);
fun(30000);
fun(30000);
toc % 結束碼表並計算時間
dist-computing 版本
tic % 碼表啟動
% 設定 jobmanager 的訊息
jobmanager_name = 'QQMOU_jobmanager';
jobmanager_hostname = 'QQMOU';
% 先連線到 job manager
jm = findResource('scheduler', 'type', 'jobmanager', ...
'name',jobmanager_name,'LookupURL',jobmanager_hostname);
% 在 job manager 裡建立一個 job
j = createJob(jm);
% 設定檔案分享
set(j,'FileDependencies',{'fun.m'})
% 描述 job 裡的 tasks
createTask(j, @fun, 1, {30000});
createTask(j, @fun, 1, {30000});
createTask(j, @fun, 1, {30000});
createTask(j, @fun, 1, {30000});
createTask(j, @fun, 1, {30000});
createTask(j, @fun, 1, {30000});
createTask(j, @fun, 1, {30000});
createTask(j, @fun, 1, {30000});
createTask(j, @fun, 1, {30000});
createTask(j, @fun, 1, {30000});
createTask(j, @fun, 1, {30000});
createTask(j, @fun, 1, {30000});
% 提交 job
submit(j);
waitForState(j);
% 取回運算資料
results = getAllOutputArguments(j)
% 運算資料存放的形式是 cell
% 可以用 cell2mat 轉回 matrix
% 砍掉已經結束的 jobs
destroy(j);
toc
----
Reference
[1] Matlab Online Help, Distributed Computing Toolbox
[2] Distributed Computing Toolbox User's Guide
http://www.mathworks.com/access/helpdesk/help/pdf_doc/distcomp/distcomp.pdf
[3] MATLAB Distributed Computing Engine System Administrator's Guide
http://www.mathworks.com/access/helpdesk/help/pdf_doc/mdce/mdce.pdf
[4] "Stage 2: Configure Your Cluster"
http://0rz.net/be1Jx
[5] "Stage 4: Test Your Distributed Computing Environment"
http://0rz.net/011Hq
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.113.128.237
推
08/16 21:01, , 1F
08/16 21:01, 1F
→
08/16 21:02, , 2F
08/16 21:02, 2F
→
08/16 22:15, , 3F
08/16 22:15, 3F
→
08/16 22:16, , 4F
08/16 22:16, 4F
→
08/16 22:16, , 5F
08/16 22:16, 5F
推
08/19 03:01, , 6F
08/19 03:01, 6F
※ 編輯: lihgong 來自: 140.113.236.184 (05/21 13:18)
MATLAB 近期熱門文章
PTT數位生活區 即時熱門文章