Difference between revisions of "MATLAB 2016"
m (→Using MATLAB with the HPC cluster: changed ntasks-per-node to ncpus-per-task) |
|||
Line 33: | Line 33: | ||
# Write a SLURM batch job script that calls MATLAB and runs a pre-defined MATLAB program. You can use a complete compute node for this if you allocate the resources accordingly. Explanations may follow in the future. | # Write a SLURM batch job script that calls MATLAB and runs a pre-defined MATLAB program. You can use a complete compute node for this if you allocate the resources accordingly. Explanations may follow in the future. | ||
# Run MATLAB interactively on a compute node using srun: | # Run MATLAB interactively on a compute node using srun: | ||
srun --nodes=1 -- | srun --nodes=1 --cpus-per-task=24 -p all_nodes.p matlab | ||
MATLAB only runs in text-based mode this way (even without the -nodisplay option). | MATLAB only runs in text-based mode this way (even without the -nodisplay option). | ||
Revision as of 10:09, 29 March 2017
Introduction
MATLAB is a commercial software product of Mathworks Inc. for solving mathematical and scientific problems and for displaying results graphically. MATLAB is primarily designed for numerical calculations with matrices, the name was derived from that purpose: MATrix LABoratory.
MATLAB at the University Oldenburg
A campus license agreement provides access to MATLAB, Simulink and a variety of toolboxes for all students, scientists, and employees at the University Oldenburg. The licensed software products may be installed on computers in the campus network and on laptops and computers at home. While the license agreement is running the software can be used for as long as you are a member of the University (as student or employee). The software can be used for teaching and research only, commercial applications are explicitly prohibited by the license agreement.
If you want to use MATLAB you can find instructions on downloading and installing the software at the web pages of IT services (German only). You may need to contact your local system administrator for help. It is recommended to install a recent version of MATLAB to get the most features and also optimal performance.
Using MATLAB with the HPC cluster
On the HPC clusters MATLAB is installed, the command
module spider matlab
will show you which versions are available. To run MATLAB you need to load the module for the desired version, e.g.
module load MATLAB/2016b
(note that unlike the spider command, the load command is case-sensitive). After that you can start MATLAB with
matlab
or
matlab -nodisplay
if you have not enabled X-forwarding at login.
Please note that MATLAB should not be used on the login nodes for compute-intensive applications. In that case you should submit a MATLAB job to the cluster which is then executed on the compute nodes. There are three ways of running MATLAB on a compute node:
- Use MATLAB Distributed Compute Server (MDCS) to submit MATLAB jobs from your desktop computer to the cluster. This is the recommended way, and is explained in detail in this Wiki (see below).
- Write a SLURM batch job script that calls MATLAB and runs a pre-defined MATLAB program. You can use a complete compute node for this if you allocate the resources accordingly. Explanations may follow in the future.
- Run MATLAB interactively on a compute node using srun:
srun --nodes=1 --cpus-per-task=24 -p all_nodes.p matlab
MATLAB only runs in text-based mode this way (even without the -nodisplay option).
IMPORTANT NOTE: Make sure you are not using more compute cores than allocated when using options 2. or 3. above. Per default MATLAB will automatically detect the number of compute cores in a node and may try to use all of them. Since compute nodes are a shared resource this may interfere with other jobs! To avoid this problem you can:
- allocate a compute node exclusively (see SLURM examples on how to achieve this)
- limit the number of compute threads in MATLAB by adding the line
maxNumCompThreads(N)
to your MATLAB code. N is the number of compute threads and it must match the --ntasks-per-node setting of your job allocation.
MATLAB Distributed Compute Server
The MATLAB Distributed Compute Server (MDCS) is a special mechanism that allow users to setup and submit jobs in MATLAB from their own computer (desktop, laptop). The job is then scheduled and executed on the cluster. The results are returned back to your own MATLAB session. This is the recommended procedure for using MATLAB on the HPC cluster and itt requires to configure MATLAB on your local computer once. The configuration of MATLAB is explained in detail on the next page, the steps to take are:
- Install MATLAB on your computer (version must be available on the cluster, too).
- Configure MATLAB for MDCS on your computer.
Once the setup has been done, you can start submitting jobs to the cluster as explained in MDCS examples page. Further information can be found on the MDCS tutorial pages and on the Mathworks web page.