|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 TimeoutWhen your interactive MATLAB session has been idle for 4 hours or more you will find MATLAB still open on your desktop. However, you will see the following message displayed in the Command Window:
"Your MATLAB session has timed out. All license keys have been returned."
This does not mean your MATLAB session has closed or exited. It just means the licenses in use have been returned to the license server. To resume a timed-out MATLAB session, just start using MATLAB again. If a license key is available, MATLAB checks it out automatically. Likewise, as you use the toolboxes and other products that you had checked out, MATLAB obtains license keys for these products as well. If a license key is not available, MATLAB periodically attempts to check out a license, issuing warning messages. After 10 warnings, if a license key is still not available, MATLAB will save the workspace and exit.
Submitting a single Matlab jobTo 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/bash # #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
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.
Passing parameters to a Matlab batch job
You can set up a batch script and pass parameters to the job at the time of submission. For example:
In the script above, the values of a, b and c are expected to be passed to the script at the time of submission, in the qsub command. Submit this job with:
#!/bin/bash # #PBS -N Matlab #PBS -m be #PBS -j oe date echo "a is $a, b is $b, c is $c"; matlab -nodesktop << EOF #starts Matlab d = sqrt(($a + $b + $c/pi)); d exit EOF #end of Matlab commands
qsub -v a=10,b=20,c=30 -l nodes=1 matlab.bat
The output from this Matlab process will go into the standard output for the job, a file called Matlab.o###### (where ##### is the job number) in the current working directory. Click here to see the output.
Submitting a swarm of Matlab jobs
The swarm program is a convenient way to submit large numbers of jobs. You create a swarm command file containing a single line for each independent job. The swarm program will then package up the commands into batch jobs and submit them to the batch system. 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 [...]
Submit this swarm command file matlab_swarm_jobs to the batch system with the command:
swarm -R matlab=1 -f matlab_swarm_jobs or swarm -R matlab=1,matlab-bio=1 -f matlab_swarm_jobs
depending on which Matlab licenses (resources) are required. More information about Matlab resources is in the next section.Regardless of the number of commands in your swarm command file, you should always specify 'matlab=1' and never a larger number. Swarm will automatically request one Matlab license for each submitted job.
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:g4,matlab=1 my_job_scripttells PBS that one Matlab license is required ('matlab=1'), as well as a node with 4Mb memory ('g4').
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:
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 18.104.22.16801 (R14) May 06, 2004 >> .... >> exit p574% exit logout qsub: job 801552.biobos completed biowulf%
Total and free licenses, the resource name, and the per-user license limit can be seen by typing 'licenses' at the Biowulf prompt or by checking this webpage. The available toolboxes and corresponding resource names are also listed in the following table:
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.
Matlab CompilerThe number of simultaneous Matlab jobs on the Biowulf cluster is limited by the number of Matlab licenses. An alternative is to compile your Matlab program using the Matlab compiler. Compiled programs do not require a Matlab license to run, so you can run a large number of simultaneous jobs. See Matlab compiler on Helix for details on how to use the compiler.
Since there is only one compiler license, and compilation can take a while, it may happen that the compiler license is not accessible at the time you want to compile. One way to avoid this problem is to submit your compilation as a batch job. The batch script would look something like this:
#!/bin/bash # #PBS -N Matlab #PBS -m be #PBS -k oe cd /data/user/myprogs mcc -m matlab_file
This script would be submitted with:
qsub -l nodes=1,matlab-compiler=1 batchscript
The job will remain in the queue until a Matlab compiler license is available. You can check the status of the job with qstat -f jobnumber: while the job is still waiting for a license, the output from this command will report:
comment = Insufficient amount of server resource matlab-compiler
Run the Matlab GUI interactivelyIf 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&
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 22.214.171.1241 (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 $
DocumentationRun Matlab in Batch mode on Unix Machines
Matlab's Search Results on Batch
Batch Queuing System on Biowulf
The Mathworks Homepage