Biowulf at the NIH
Matlab on Biowulf
Matlab logoMatlab integrates mathematical computing, visualization, and a powerful language to provide a flexible environment for technical computing. The open architecture makes it easy to use MATLAB and its companion products to explore data, create algorithms, and create custom tools that provide early insights and competitive advantages.
Submitting a single Matlab job
To submit Matlab scripts to the batch queue, first create a batch script file (a csh or bash file) that contains any desired PBS options and the commands to run Matlab non-interactively.

NOTE: The scripts on this page are very simple and are used ONLY as examples on how to submit jobs to the Biowulf cluster. Of course, users will typically submit much more compute-intensive jobs.

Sample file matlab.script

#!/bin/tcsh
#
#PBS -N Matlab
#PBS -m be 
#PBS -k oe
 
date

/usr/local/bin/matlab -nodesktop << EOF       #starts Matlab
a = 10;                                       #Matlab commands
b = 20;
c = 30;
d = sqrt((a + b + c)/pi);
exit
EOF                                            #end of Matlab commands

Submit the script using the qsub command, e.g.
qsub -l nodes=1,matlab=1 /full/pathname/matlab.script

This qsub command requests one Matlab license ('matlab=1'), so the job will remain in the queue until a license is available. You will receive email when the job is executed and when it ends, because of the line PBS -m be in the script.

Submitting a swarm of Matlab jobs
The swarm program is a convenient way to submit large numbers of jobs. Each command is represented by a single line in the swarm command file that you create, and runs as a separate batch job. See the swarm page. for more information.

Create a swarm command file, named matlab_swarm_jobs for instance, with each line containing a single executable script.

Sample Matlab swarm command file:

/usr/local/bin/matlab -nodesktop < /data/user/run1.m
/usr/local/bin/matlab -nodesktop < /data/user/run2.m
/usr/local/bin/matlab -nodesktop < /data/user/run3.m
[...]
where each .m file contains a sequence of Matlab commands.

Submit this swarm command file matlab_swarm_jobs to the batch system with the command:

swarm -f matlab_swarm_jobs -l nodes=1,matlab=1
or
swarm -f matlab_swarm_jobs -l nodes=1,matlab=1,femlab=1,matlab-bio=1

depending on which Matlab licenses (resources) are required. More information about Matlab resources is in the next section.

Note that an unlimited number of jobs can be submitted to the queue, but the number that will actually run simultaneously depends on the per-user Matlab license limit, and the number of available licenses. The batch system will restrict the number of Matlab licenses that are allocated to an individual user. This limit is subject to change depending on the number of licenses and usage.

Matlab resources (licenses)
The PBS Batch system on the Biowulf cluster keeps track of the Matlab licenses via the Matlab "resources". Jobs requiring a Matlab license will be started or remain in the queue depending on the availability of Matlab licenses. All Matlab jobs must therefore specify the appropriate resource when the job is submitted. For example,
qsub -l nodes=1:m2048,matlab=1 my_job_script
tells PBS that one Matlab license is required ('matlab=1'), as well as a node with 2Mb memory ('m2048').

Similarly, a job that requires the Bioinformatics toolbox should be submitted as:

qsub -l nodes=1,matlab=1,matlab-bio=1 my_job_script
(Note that both a Matlab license and Bioinformatics Toolbox license is required).

If using Matlab interactively, the same resources must be specified:
(user input in bold)

biowulf% qsub -I -l nodes=1,matlab=1
qsub: waiting for job 801552.biobos to start
qsub: job 801552.biobos ready

p574% matlab
                                       < M A T L A B >
                           Copyright 1984-2004 The MathWorks, Inc.
                                  Version 7.0.0.19901 (R14)
                                         May 06, 2004
>> ....
>> exit

p574% exit
logout

qsub: job 801552.biobos completed

biowulf%
It is VERY IMPORTANT to exit the interactive shell as well as Matlab, otherwise the batch system will not release the resource.

The available toolboxes and corresponding resource names are listed in the following table:

Toolbox Resource # licenses
Matlab matlab 18
Bioinformatics Toolbox matlab-bio 1
Curve Fitting Toolbox matlab-curve 2
Identification Toolbox matlab-id 2
Image Processing Toolbox matlab-image 2
Neural Network Toolbox matlab-neural 2
Optimization Toolbox matlab-opt 3
Partial Differential Equation (PDE) Toolbox matlab-pde 2
SB2SL (Converts System Build to Simulink) -
Signal Processing Toolbox matlab-signal 6
SimBiology Toolbox - 1
Spline Toolbox matlab-spline 1
Statistics Toolbox matlab-stat 5
Symbolic Math Toolbox matlab-symb 2
Wavelet Toolbox matlab-wave 2
CGH-Plotter -
EEGLAB -
P-SCAN -
SPM2 -

A '-' indicates that the toolbox is not licensed, and therefore no resource needs to be specified. Note that an unlimited number of jobs can be submitted to the queue, but they will run depending on the number of available licenses and the per-user license limit.

Run the Matlab GUI interactively
If you simply log in to Biowulf and give the matlab command, matlab will run on the main Biowulf login node. This is highly discouraged because the login node has only 2 processors and is not intended for running computational applications. Instead, to run matlab interactively, you should allocate a node for interactive use and run on that node, as described in the example below.

To run the MATLAB graphics interface, an X windows connection to Biowulf is required. Open an Xwindows connection to biowulf.nih.gov, and check that it is working by typing 'xclock' at the Biowulf prompt. Now allocate an interactive node with the '-V' flag to transfer all your environment variables to the computational node. Example:

     biowulf% qsub -I -l nodes=1,matlab=1 -V
     qsub: waiting for job 423061.biobos to start
     qsub: job 423061.biobos ready

     [username@p955 ~]$ matlab&
HINT: If you receive an error message that contains "Failure to Launch Desktop Class", cd to $HOME/.matlab and remove the directory R14 and try again.

You must use Xwindows software to connect to Biowulf if you want to use the Matlab GUI. For batch jobs, or for non-GUI interactive jobs, Xwindows is not required. <>

Run Matlab interactively without the GUI

It is also possible to run Matlab interactively on the command-line, without the GUI. This would typically be useful only for debugging. Again, this should be done by allocating an interactive node. Example:

     biowulf% qsub -I -l nodes=1,matlab=1,matlab-spline=1
     qsub: waiting for job 2011.biobos to start
     qsub: job 2011.biobos ready

     p139$ matlab
      
                          < M A T L A B (R) >
                  Copyright 1984-2008 The MathWorks, Inc.
                       Version 7.7.0.471 (R2008b)
                           September 17, 2008


  To get started, type one of these: helpwin, helpdesk, or demo.
  For product information, visit www.mathworks.com.
           
     >> quit
     [username@p139 ~]$ exit
     logout

     qsub: job 2011.biobos completed
     biowulf $ 

Versions

------------------------------------------------------------------------------------- MATLAB Version 7.7.0.471 (R2008b) MATLAB License Number: 35 Operating System: Linux 2.6.18-92.el5 #1 SMP Tue Jun 10 18:51:06 EDT 2008 x86_64 Java VM Version: Java 1.6.0_04 with Sun Microsystems Inc. Java HotSpot(TM) 64-Bit Server VM mixed mode ------------------------------------------------------------------------------------- MATLAB Version 7.7 (R2008b) Simulink Version 7.2 (R2008b) Bioinformatics Toolbox Version 3.2 (R2008b) Curve Fitting Toolbox Version 1.2.2 (R2008b) Image Processing Toolbox Version 6.2 (R2008b) Neural Network Toolbox Version 6.0.1 (R2008b) Optimization Toolbox Version 4.1 (R2008b) Partial Differential Equation Toolbox Version 1.0.13 (R2008b) Signal Processing Toolbox Version 6.10 (R2008b) SimBiology Version 2.4 (R2008b) Spline Toolbox Version 3.3.5 (R2008b) Statistics Toolbox Version 7.0 (R2008b) Symbolic Math Toolbox Version 5.1 (R2008b) System Identification Toolbox Version 7.2.1 (R2008b) Wavelet Toolbox Version 4.3 (R2008b)
Documentation
Run Matlab in Batch mode on Unix Machines
Matlab's Search Results on Batch
Batch Queuing System on Biowulf
Matlab Help
Matlab FAQ
The Mathworks Homepage