Difference between revisions of "MATLAB Guide"

From Storrs HPC Wiki
Jump to: navigation, search
(Changed help email to current address)
(Changed names to reflect new hostname)
Line 2: Line 2:
 
The university does not own a MATLAB distributed computing server license.  This means MATLAB will not fully be able to take advantage of our HPC resources.  If you are interested in helping to fund a MATLAB distributed computing server license, then please email hpc@uconn.edu.
 
The university does not own a MATLAB distributed computing server license.  This means MATLAB will not fully be able to take advantage of our HPC resources.  If you are interested in helping to fund a MATLAB distributed computing server license, then please email hpc@uconn.edu.
  
Currently, the HORNET cluster is configured to use the MATLAB Research floating license pool.  These licenses and toolkits are used by a great many people on campus and are in limited supply.  Please be considerate of others in reserving access to the research MATLAB licenses.
+
Currently, the the cluster is configured to use the MATLAB Research floating license pool.  These licenses and toolkits are used by a great many people on campus and are in limited supply.  Please be considerate of others in reserving access to the research MATLAB licenses.
  
= Using MATLAB on the Hornet cluster =
+
= Using MATLAB on the the cluster =
All jobs on the Hornet cluster must be submitted through the SLURM scheduler using sbatch.  The preferred way to run MATLAB jobs is using a .m file.  Please note that if your job uses many cores or a lot of memory it is better to submit to reserve a whole compute node (12 cores) in exclusive mode
+
All jobs on the the cluster must be submitted through the SLURM scheduler using sbatch.  The preferred way to run MATLAB jobs is using a .m file.  Please note that if your job uses many cores or a lot of memory it is better to submit to reserve a whole compute node (12 cores) in exclusive mode
  
 
== Loading MATLAB module ==
 
== Loading MATLAB module ==
Line 25: Line 25:
 
== Submitting .m files with slurm==
 
== Submitting .m files with slurm==
  
Please '''ssh hornet-login3.engr.uconn.edu''' to use SLURM. Here are a series of ways to run the .m file TestCluster.m
+
Please '''ssh <netid>@login.storrs.hpc.uconn.edu''' to use SLURM. Here are a series of ways to run the .m file TestCluster.m
 
===Single Core job ===
 
===Single Core job ===
 
To submit a job which uses a single core on a compute node where other jobs are running. Create a script called matlabSP.sh:
 
To submit a job which uses a single core on a compute node where other jobs are running. Create a script called matlabSP.sh:
Line 90: Line 90:
 
'''NOTE:''' *any* interruption to the network will cause your job to crash irrecoverably.
 
'''NOTE:''' *any* interruption to the network will cause your job to crash irrecoverably.
  
To run an interactive Matlab session with GUI, you should "ssh -X" to the Hornet from a Linux machine or iOS matchine with X11 enabled. Or please follow the [[X | X Apps]]. Then, run the above commands.
+
To run an interactive Matlab session with GUI, you should "ssh -X" to the the cluster from a Linux machine or iOS matchine with X11 enabled. Or please follow the [[X | X Apps]]. Then, run the above commands.
  
 
[[Category:Software]]
 
[[Category:Software]]

Revision as of 17:05, 19 February 2016

MATLAB licensing

The university does not own a MATLAB distributed computing server license. This means MATLAB will not fully be able to take advantage of our HPC resources. If you are interested in helping to fund a MATLAB distributed computing server license, then please email hpc@uconn.edu.

Currently, the the cluster is configured to use the MATLAB Research floating license pool. These licenses and toolkits are used by a great many people on campus and are in limited supply. Please be considerate of others in reserving access to the research MATLAB licenses.

Using MATLAB on the the cluster

All jobs on the the cluster must be submitted through the SLURM scheduler using sbatch. The preferred way to run MATLAB jobs is using a .m file. Please note that if your job uses many cores or a lot of memory it is better to submit to reserve a whole compute node (12 cores) in exclusive mode

Loading MATLAB module

To load the MATLAB module type

module load matlab/2012b

This will need to be done every time you login.

If you want to use MATLAB 2013b or above, please login at node 65.

ssh cn65
module load matlab/2013b

If you want to have the module loaded automatically, type "module initadd matlab/r2009b". The next time you login, the MATLAB module will be loaded.

To initially load MATLB, please issue:

module initadd matlab/2014b

Here, you can change 2014b with any other versions that you prefer.

Submitting .m files with slurm

Please ssh <netid>@login.storrs.hpc.uconn.edu to use SLURM. Here are a series of ways to run the .m file TestCluster.m

Single Core job

To submit a job which uses a single core on a compute node where other jobs are running. Create a script called matlabSP.sh:

#!/bin/bash
#SBATCH -n1
#SBATCH -p Westmere
#SBATCH -o outputfile.txt
#SBATCH -e outputfile.txt

matlab -singleCompThread -r TestCluster\;exit\;

NOTE: any ";" or " ' " after "-r" should be pre-appended by "\".

Then submit the scirpt by:

 sbatch <matlabSP.sh

Multithread job

To submit a job which uses 12 computational threads, matlabMP.sh

#!/bin/bash
#SBATCH -n1
#SBATCH -c12
#SBATCH -p Westmere
#SBATCH --exclusive
#SBATCH -o outputfile.txt
#SBATCH -e outputfile.txt

matlab -r TestCluster\;exit\;

NOTE: any ";" or " ' " after "-r" should be pre-appended by "\".

Then submit the scirpt by:

 sbatch <matlabMP.sh

How to write script for matlabpool

To run the jobs with parfor, please rewrite TestCluster as:

num_proc=str2num(getenv('SLURM_CPUS_PER_TASK'));
matlabpool('local',num_proc)

parfor i=1:40
   ...
end
matlabpool close;

Then, submit your script as:

sbatch <matlabMP.sh

Interactive MATLAB use with SLURM (not recomended)

NOTE: *any* interruption to the network will cause your job to crash irrecoverably.

To run an interactive Matlab session, you will want to do the following:

[NetID@cn65 ~]$ module load matlab/2014b
[NetID@cn65 ~]$ fisbatch -c12 -p Westmere --exclusive
FISBATCH -- the maximum time for the interactive screen is limited to 6 hours. You can add QoS to overwrite it.
FISBATCH -- waiting for JOBID 20248 to start on cluster=cluster and partition=Westmere
!
FISBATCH -- Connecting to head node (cn42)
[xxx00000@cn42 ~]$ matlab
... # here will be the interactive commands with matlab
[xxx00000@cn42 ~]$ exit
[screen is terminating]
Connection to cn42 closed.
FISBATCH -- exiting job

NOTE: please DO NOT FORGET to EXIT from the nodes so that the other users can use it.

[NetID@cn42 ~]$ matlab

NOTE: *any* interruption to the network will cause your job to crash irrecoverably.

To run an interactive Matlab session with GUI, you should "ssh -X" to the the cluster from a Linux machine or iOS matchine with X11 enabled. Or please follow the X Apps. Then, run the above commands.