MATLAB/Batch
From ScientificComputing
Assuming that you already loaded the MATLAB module and have a MATLAB program simulation.m you would like to run, the command to submit a job to the batch system would look like
sbatch [Slurm options] --wrap="matlab -nodisplay -nojvm -singleCompThread -r simulation"
Please note, that you have to leave away the file ending .m. Here you need to replace [Slurm options] with Slurm parameters for the resource requirements of the job. Please find a documentation about the parameters of sbatch on the wiki page about the batch system.
We suggest you include the extra options shown above:
- -nodisplay
- since jobs on compute nodes are not run interactively, this flag explicitly tells Matlab that no graphical display (X server) is available is available.
- -singleCompThread
- forces Matlab to use only one thread for its computations. This option is crucial to prevent MATLAB from overloading the compute nodes.
- -nojvm
- (optional) prevents the JVM (Java virtual machine) from being used. Add this flag unless you need the JVM, such as the with the PCT (Parallel Computing Toolbox).
For submitting parallel MATLAB jobs, please have a look at the tutorials about running MATLAB in parallel.