Skip to content

How to submit non-interactive MATLAB scripts to the queues

See the MATLAB page for details on selecting MATLAB versions, compilation and using compilation runtimes.

For non-interactive MATLAB, it is more efficient to compile your code (see the MATLAB page).

When using MATLAB 2019a onwards, there is a new command line option -batch specifically for running MATLAB in the most efficient manner on compute clusters. Unfortunately, when run in this mode, MATLAB only accepts simple commands, so if your script is in a file called mytask.m then you would call with:

fsl_sub -R 16 -T 100 matlab -batch "run('mytask.m')"

For older MATLAB versions then the equivalent would be:

fsl_sub -R 16 -T 100 matlab -nodisplay -nosplash \< mytask.m

Note

The "\" is very important since MATLAB won't read your script otherwise.

Warning

The -batch option must be used when submitting batch jobs (where supported), as otherwise you are likely to rapidly run out of home folder space due to MATLAB writing logs related to the 'MATLAB Connector'.

Warning

MATLAB tasks will often attempt to carry out some operations using multiple threads. Our cluster is configured to run only single thread programs unless you request multiple threads. SLURM will enforce these limits so preventing MATLAB from overloading the system, but it may be advisable to limit the number of threads MATLAB uses to ensure optimum performance.

Once the task is running you can look at the file matlab.o<jobid> for any output.

If you wish to take advantage of the multi-threaded facilities in MATLAB request multiple cores with the -s option to fsl_sub.

Where you must interact with the process see the section on the MATLAB gui within the VDI.