Running MATLAB jobs In Batch
MATLAB applications may be divided into two categories: interactive and non-interactive. Interactive sessions are typically used for prototyping, for one-time computation or visualization, or for tasks that are interactive in nature ( e.g., the next MATLAB action is conditional on the outcome of the previous). Non-interactive type of applications require no interaction between the user and the MATLAB environment.
On our linux cluster, users are encouraged to run MATLAB jobs through batch
to ease the load on the login nodes. If you need to run interactive MATLAB jobs,
interactive batch is ideally suited for the purpose. An added advantage in
using the interactive batch is that you will be assigned a dedicated node and
because you are not sharing the node with other users, your MATLAB command gets processed
immediately. On the other hand,
if your job is a production run that requires no interaction with MATLAB,
then just submit it as a non-interactive batch job.
Interactive Batch
To prevent overburdening the Cluster's login nodes, cootie and skate, we encourage users to run MATLAB, or other similar computationally and graphically intensive applications, via interactive batch. Think of interactive batch as a means to check out a compute node for your own exclusive use. By running an interactive MATLAB session in this mode, you could see speedups on your MATLAB applications since you are the only user on this node. Users who do not need to run MATLAB applications in an interactive manner can submit their m-files as non-interactive batch jobs.
-
qsub -I
If a node is available, the current shell (window) will turn into a new shell (in the same window) which represents the assigned node. Notice that the system prompt turns from "cootie" to,
in this case, "node052".
cootie:run/tmp % qsub -I
qsub: waiting for job 25441.hn003.nerf.bu.edu to start
qsub: job 25441.hn003.nerf.bu.edu ready
----------------------------------------
Begin PBS Prologue Thu Aug 12 08:44:16 EDT 2004
Job ID: 25441.hn003.nerf.bu.edu
Username: kadin
Group: scv
Nodes: nodem052
End PBS Prologue Thu Aug 12 08:44:17 EDT 2004
----------------------------------------
node052:~ %
Please note that the default time limit on interactive batch queues is two hours. Longer runtime
may be requested as follows:
cootie% qsub -I -l walltime=04:00:00
The above interactive batch session will last up to four hours.
Now that you have access (i.e., system prompt) to node052, you can do anything with it that
you could with cootie, such as starting a MATLAB session.
- If your interactive session does not involve any graphical displays, you can run MATLAB as follows:
node052:~ % matlab -nodisplay -nosplash -nojvm
Steps 3 and 4 below are needed only if you anticipate graphics in your interactive
session.
- If your interactive session involves graphical displays, before running MATLAB, you need to
permit graphical display coming from node052 to display on your local host machine. As a matter of fact, the window you are in right now must be an X-window already. If you don't have
x-window on your local host, you can
download it for free. Come back here when you have installed x-window. Your local host
is represented either by a pre-designated name or an IP address.
For Linux
- To find the IP address:
local-machine % ping $HOST
node052:~ % setenv DISPLAY IP-ADDRESS:0
For example,
node052:~ % setenv DISPLAY 128.197.123.456:0
- Next, you need to give it the permission
for the client (node052 in this case) to display on it
host-machine %xhost + ware.bu.edu
(This works for any node number)
- Ready to go ...
At this point, you are all set to run MATLAB.
node052:~ % matlab
A popup window will appear, asking you to
accept or refuse MATLAB display on your machine. Click OK to accept.
You may have to click OK multiple times as running MATLAB
results in the spawning of multiple windows and hence each of these
windows causes a request to accept or refuse display.
Non-interactive batch
This section covers the type of MATLAB jobs that do not require any interaction
between the user and MATLAB.
To facilitate MATLAB batch processing, a script, called msub, has been written.
Because msub is not a system script, you will need to copy it (left click to view and right-click to copy) into your local directory, like ~/bin. Remember to give this script an
execute attribute with
cootie % chmod +x msub
Here is a simple application of msub.
cootie % msub example.m outputfile
In the above, example.m is your m-file (or the primary m-file
which in turn calls other m-files) and outputfile is the file name to which your MATLAB output will go.
The above example implies a (system default) two-hour wallclock time limit.
You can request up to 24 hours wallclock time for your run. For a 4-hour
wallclock limit, the above example becomes
cootie % msub example.m outputfile "-l walltime=04:00:00"
The third, optional, input argument is there so that you may pass options for the qsub command if need be.
Your submitted batch job will have the name msub.USERID, where USERID is your user ID.
Please note that if your m-file contains any graphics applications such as plot, surf, or patch, you need to use the MATLAB print command to save it to an image file for later viewing or printing.
Sample m-file, example.m:
x = 1:4
disp('this is a test')
plot(x,x)
print -deps myplot % save the plot as myplot.eps (postscript format)
exit % need this for batch
Note in the above that the MATLAB print command is used to save
the plot to a file called myplot.eps. The graphics output format
is eps. Unfortunately, the jpeg format - though very popular
- is not permitted by MATLAB in the batch mode. At the MATLAB prompt (>>), type help print for print format options.
|
|