Submit job to specified workers in an MJS cluster
3 views (last 30 days)
Data Analysis on 21 Dec 2015
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?
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
[~, q, ~, ~] = findJob(c);
if q(1) == j
% Wait for all other jobs to finish running
[~, ~, runningJobs, ~] = c.findJob;
% 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']);