biowulf_logo

Status
About
Hardware
Applications
Batch queues
Disk storage
MPI
Performance
New Users
User Guide
Documentation
Research
Photos


tmw_logo

Matlab on Biowulf

Matlab 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.


Matlab jobs on Biowulf

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. Example below: NOTE: The scripts on this page are very simple and are used ONLY as examples on how to submit jobs to the Biowulf cluster. 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, 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 swarm 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 only 6 will run at any given time. 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

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 a Matlab license is required, as well as a node with 2Mb memory.

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:
ToolboxResource # licenses
Matlab matlab18
Bioinformatics Toolbox matlab-bio 1
Curve Fitting Toolbox matlab-curve2
Identification Toolbox matlab-id2
Image Processing Toolbox matlab-image2
Neural Network Toolbox matlab-neural2
Optimization Toolbox matlab-opt3
Partial Differential Equation (PDE) Toolbox matlab-pde2
SB2SL (Converts System Build to Simulink) -
Signal Processing Toolbox matlab-signal6
SimBiology Toolbox - 1
Spline Toolbox matlab-spline1
Statistics Toolbox matlab-stat5
Symbolic Math Toolbox matlab-symb2
Wavelet Toolbox matlab-wave2
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 only 4 will run at any given time. The batch system will restrict the number of Matlab licenses that are allocated to an individual user. The toolbox licenses are currently not restricted.


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 biobos.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 X software to connect.

Run Matlab interactively without the GUI

It is also possible to run Matlab interactively on the command-line, without the GUI. This would be useful only if there's no way to get an Xwindows connection. 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 >
         Copyright 1984-2003 The MathWorks, Inc.
      Version 6.5.1.199709 Release 13 (Service Pack 1)
                      Aug  4 2003

     Using Toolbox Path Cache.  Type "help toolbox_path_cache" for more info.
 
     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
     biobos$ 

Versions

-------------------------------------------------------------------------------------
MATLAB Version 7.0.1.24704 (R14) Service Pack 1
MATLAB License Number: 35
Operating System: Linux 2.4.20-28.7smp #1 SMP Thu Dec 18 11:18:31 EST 2003 i686
Java VM Version: Java 1.4.2_05 with Sun Microsystems Inc. Java HotSpot(TM) Client VM
-------------------------------------------------------------------------------------
MATLAB                                                Version 7.0.1      (R14SP1) 
Simulink                                              Version 6.1        (R14SP1) 
Bioinformatics Toolbox                                Version 2.0        (R14SP1+)
Curve Fitting Toolbox                                 Version 1.1.2      (R14SP1) 
Image Processing Toolbox                              Version 5.0.1      (R14SP1) 
Neural Network Toolbox                                Version 4.0.4      (R14SP1) 
Optimization Toolbox                                  Version 3.0.1      (R14SP1) 
Partial Differential Equation Toolbox                 Version 1.0.6      (R14SP1) 
Signal Processing Toolbox                             Version 6.2.1      (R14SP1) 
Spline Toolbox                                        Version 3.2.1      (R14SP1) 
Statistics Toolbox                                    Version 5.0.1      (R14SP1) 
Symbolic Math Toolbox                                 Version 3.1.1      (R14SP1) 
System Identification Toolbox                         Version 6.1        (R14SP1) 
Wavelet Toolbox                                       Version 3.0.1      (R14SP1) 

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


This document is available as http://biowulf.nih.gov/apps/matlab.html
Biowulf home page | Helix Systems | NIH