Using System() to submit cluster job to SLURM but gives "sbatch: command not found" error.
34 views (last 30 days)
Show older comments
Yanke on 21 Oct 2022
Answered: Raymond Norris on 22 Oct 2022
I am converting a code written for LSF workload manager to a cluster that uses SLURM. The MATLAB code includes a line that submit a .sh job script to the cluster (linux), so I changed the 'bsub' command for LSF to 'sbatch' for SLURM. However, the 'command not found' error still pops out.
One way to get rid of the erro is to add the trailing character '&' at the end of the system command as suggested on the website https://www.mathworks.com/help/matlab/ref/system.html . However, although the error no longer pops out and the 'status=0' is shown (which usually means program runs correctly), the output file the .sh file is suppose to write does not appear.
strFn_O = '/dev/null';
strFn_E = '/dev/null';
sysClusterCmd = ['$ sbatch --ntasks=1 --job-name=007 --output=' strFn_O ' --error=' strFn_E ' S1_C1_0001.sh &'];
My question would be, how to change the code to write the output file in the correct folder?
I use a shell to invoke the matlab that again invoke a shell. Is that a problem?
Raymond Norris on 22 Oct 2022
I suspect the command not found is for sbatch. If so, I would suggest hardcoding the location of it in your path. For example
sysClusterCmd = ['$ /path/to/slurm/bin/sbatch --ntasks=1
With that said, I don't know what the leading "$" is for. Have you tried removing it?
Also, programatically, I would suggest calling system as such (for example)
[FAILED, result] = system(sysClusterCmd);
% Command failed. Display "result" in an error.
Find more on Cluster Configuration in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!