简体   繁体   中英

determining matlab parallel pool size in a batch job on a cluster

I want to verify that my cluster is configured correctly, and I thought issuing the command below will run the following script and output the poolsize into a text file as well as where my screen output is directed (by the batch management environment). Instead I only see output at the end, with nothing in the error file either. How shall I get this done?

Command:

matlab -nosplash -nodesktop < test.m

Script:

clear;
delete(gcp);
parpool;
poolsize = poolobj.NumWorkers
save poolsize.txt poolsize -ascii
exit();
poolobj = gcp('nocreate'); % If no pool, do not create new one.
if isempty(poolobj)
    poolsize = 0;
else
    poolsize = poolobj.NumWorkers
end
save poolsizefile poolsize;
poolsize
exit();

(The second half never worked, so I even stopped trying, thus the first exit.)

Output:

>> >> Starting parallel pool (parpool) using the 'local' profile ... Warning: Found 1 pre-existing communicating job(s) created by pool that are
running, and 3 communicating job(s) that are pending or queued. You can use
'delete(myCluster.Jobs)' to remove all jobs created with profile local. To
create 'myCluster' use 'myCluster = parcluster('local')'. 

Firstly, I would suggest using the -r option to MATLAB to run your script as there are some occasional weirdnesses when piping input as you're doing, eg

matlab -nodisplay -r test

Then, I would change line 2 to state

delete(gcp('nocreate'))

to ensure you don't create a pool simply to delete it. Then, the next bit should be

poolobj = parpool;
poolsize = poolobj.NumWorkers;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM