Submit job to specified workers in an MJS cluster

1 view (last 30 days)
My tasks consume a large amount of memory so that I should not submit more than 5 tasks to each node in our group cluster (each node has 8 workers). Can I tell MJS to use only 5 workers in each node? If not possible, can we do it manually?
  1 Comment
Peter Schwander
Peter Schwander on 7 Jan 2020
I have a somewhat related question. In MATLAB R2019a, I want that have successive tasks to go on different worker nodes. This was possible e.g. in MATLAB2015b by chosing appropriate names for the workers, i.e.
./startworker -name worker000 -jobmanagerhost -remotehost compute-0-0 -v -clean
./startworker -name worker001 -jobmanagerhost -remotehost compute-0-1 -v -clean
./startworker -name worker002 -jobmanagerhost -remotehost compute-0-2 -v -clean
./startworker -name worker003 -jobmanagerhost -remotehost compute-0-3 -v -clean
However, with MATLAB R2019a, this scheme does not work anymore.

Sign in to comment.

Accepted Answer

Thomas Ibbotson
Thomas Ibbotson on 4 Jan 2016
Unfortunately, this is not possible. You could temporarily reduce the number of workers on each node to 5. The MJS startworker and stopworker scripts can be run remotely from the client machine. Of course you would not want to stop a worker that was running someone else's job, so you would need to pause the queue and wait for all other jobs to finish running first.
Something a bit like this (untested) code should work (replace 'MyMJSProfile' with your MJS profile):
c = parcluster('MyMJSProfile');
% Pause the queue so no more jobs will run
% Create and submit our job to the queue
j = batch('myJobScript');
% Promote the job to the top of the queue so it will
% run next
while true
[~, q, ~, ~] = findJob(c);
if q(1) == j
promote(c, j);
% Wait for all other jobs to finish running
[~, ~, runningJobs, ~] = c.findJob;
if ~isempty(runningJobs)
% Now run stopworker on each node until there are only 5 workers on each node.
% Note I've missed out the code that loops through the nodes and stops the
% right number of workers.
system([matlabroot '/toolbox/distcomp/bin/stopworker -remotehost myNode1 -name myWorker1']);
% Resume the queue so the job runs
% The job has finished now so we can start the workers again
system([matlabroot '/toolbox/distcomp/bin/startworker -remotehost myNode1 -name myWorker1']);

More Answers (0)

Community Treasure Hunt

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

Start Hunting!