Using System() to submit cluster job to SLURM but gives "sbatch: command not found" error.
20 次查看(过去 30 天)
显示 更早的评论
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 &'];
system(sysClusterCmd);
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?
0 个评论
回答(1 个)
Raymond Norris
2022-10-22
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);
if FAILED~=false
% Command failed. Display "result" in an error.
end
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Third-Party Cluster Configuration 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!