Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Info

Matlab's Parallel Toolbox does not work well if you set a shell preference in your SGE request. If you otherwise use a #$ -S <shell> designation in your SGE qsub scripts, it is best to remove or comment them when submitting parallel Matlab jobs.


Info
This example demonstrates the -nojvm which disables some of Matlab's features in order to start faster and use less memory. This helps maintain the cluster's performance if you have a large batch of jobs which don't require the disabled features.


Code Block
languagebash
titleSimple Matlab batch job: mat-test.sh
#!/bin/bash
# The name of the job:
#$ -N MatlabTest
# Name of the output log file:
#$ -o matjob.log
# Combining output/error messages into one file:
#$ -j y
# Specifying the Queue
#$ -q UI
# One needs to tell the queue system to use the current directory as the working directory
#$ -cwd
# The command(s) to be executed:
matlab -nodisplay -nodesktop -nojvm -r batch
# Note after -r is the name of the routine or function

...

Submit the job using 'qsub parallel-test.sh', assuming the name of the submission script is called parallel-test.sh.

Info

Matlab's Parallel Toolbox requires Java, so if your code uses features of the toolbox, you must omit the -nojvm option when invoking matlab, otherwise your code will quit with an uninformative error. You can verify Java is available and otherwise deliberately quit with a helpful error message by adding this command before code which uses a feature requiring Java:

error(javachk('jvm'))


Code Block
languagebash
titleExample Parallel Job: parallel-test.sh
#!/bin/bash
# The name of the job:
#$ -N test        ## replace 'test' with job name 
# Name of the output log file:
#$ -o matlabTest_parfor.log
# Combining output/error messages into one file ( change y to n for separate files)
#$ -j y
# Specify the parallel environment (PE) and number of cores to use (8):
#$ -pe smp 8
# One needs to tell the queue system to use the current directory as the working directory
#$ -cwd
# The matlab commands to be executed; replace "test" with your function name. 
# -r imediately runs a function without presenting an interactive prompt
/opt/matlab/R2012b/bin/matlab -nodisplay -nodesktop -nosplash -r parafor-test

...