Running MATLAB script that uses parallel processing from a windows batch file

7 ビュー (過去 30 日間)
Darrell
Darrell 2017 年 1 月 17 日
コメント済み: Darrell 2017 年 1 月 26 日
I'm stumped on how to run a MATLAB script that uses parallel processing from a windows batch file without having the overhead of starting a new parpool each time the code (or Matlab session) executes. Note. I am running this all on my 'local' computer.
Specifically, when I execute the following windows batch file to run a Matlab sript, i.e.'mywave.m'; each time I execute the batch file, the new Matlab session starts a new parpool on my 'local' machine which incurs about 25 seconds of overhead time. Since I had already created a parpool, how can I utilize the existing parpool without starting/creating an entirely new parpool each time I execute my windows batch file?
For example, after creating the initial parpool, I execute the the following windows batch file to execute my Matlab script file:
"D:\Program Files\MATLAB\R2016b\bin\matlab.exe" -nodisplay -nosplash -nodesktop -r "try, run('D:\Matlab\Work\mywave.m'), catch, exit, end; exit;"
Code for ('mywave.m')
parfor i = 1:1024
A(i) = sin(i*2*pi/1024);
end
Therefore, is it possible to run Matlab from the windows command line and utilize an existing parpool? And if so, how?
Thanks in advance.

採用された回答

Jonathan Kwang
Jonathan Kwang 2017 年 1 月 23 日
Unfortunately, if you exit MATLAB while the parallel pool is running, the parallel pool shuts down along with MATLAB so new parallel pool would need to be started when another instance of MATLAB is started.
  2 件のコメント
Walter Roberson
Walter Roberson 2017 年 1 月 23 日
Is this something that MATLAB Production Server could help overcome? Or perhaps the Distributed Computing Server might allow the workers to be "kept warm" ?
Darrell
Darrell 2017 年 1 月 26 日
Thanks for the response; unfortunately I was afraid that was going to be the answer. However, it would be nice if you could add an argument to call an existing Matlab session from the command line. That would save a lot of time from having to load Matlab and creating a new pool of workers.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeParallel Computing Fundamentals についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by