Matlab¶
Description¶
MATLAB is a computing platform that is used for engineering and scientific applications like data analysis, signal and image processing, control systems, wireless communications, and robotics. MATLAB includes a programming language, interactive apps, highly specialized libraries for engineering applications, and tools for automatically generating embedded code. MATLAB is also the foundation for Simulink, a block diagram environment for simulating complex multi-domain systems.
Versions¶
Following versions of Matlab are currently available:
- Runtime dependencies:
- None, required libraries and dependencies are loaded automatically with the
matlab/R2024bmodule.
- None, required libraries and dependencies are loaded automatically with the
You can load the matlab module by following command:
module load matlab/R2024b
Best practice for using Matlab¶
Matlab calculations can be run in different ways. You can run script from command line. In case you need interactive GUI you can launch it via Open Ondemand platform. You can also run the calculations from your local Matlab client using Matlab Parallel Server. In any case the recommended approach is to tune your script on your local computer first. After your sript is optimized then exploit the resources on supercomputer using one of the methods.
Example run script¶
If you have a matlab script named script.m you can copy and modify the following script and save it as matlab_run.sh, then submit job to a compute node by command sbatch matlab_run.sh
#!/bin/bash
#SBATCH --partition=short
#SBATCH --job-name=matlab
#SBATCH --nodes=1
#SBATCH --output=output.txt
#SBATCH --error=error.txt
#SBATCH --ntasks=1
#SBATCH --mem=3750
module load matlab/R2024b
matlab -nodisplay -nosplash -nodesktop -r "run('script.m'); exit"
Open Ondemand application¶
If you prefer interactive GUI, you can run MATLAB application via Open Ondemand platform. Find it in Interactive apps, fill in the form and launch.
Matlab Parallel Server¶
It is possible to submit jobs to slurm scheduler directly from your local Matlab client using Matlab Parallel Server (MPS).
Create Cluster Profile and Validate Installation¶
- Start the Cluster Profile Manager. On the Home tab, in the Environment area, select Parallel > Create and Manage Clusters.
- Create a new profile in the Cluster Profile Manager by selecting Add Cluster Profile > Slurm
- With the new profile selected in the list, click Rename and edit the profile name to be Devana. Select Enter.
- Download Parallel Computing Toolbox plugin for MATLAB Parallel Server with Slurm from https://github.com/mathworks/matlab-parallel-slurm-plugin. You can either git clone it or download as ZIP archive and extract to desired location.
- In the Properties tab, provide settings for the following fields:
| Property | Value |
|---|---|
| Description | Devana |
| JobStorageLocation | C:\Temp\joblocation |
| NumWorkers | inf |
| NumThreads | 1 |
| ClusterMatlabRoot | /storage-apps/software/Matlab/R2024b/ |
| RequiresOnlineLicensing | false |
| HasSharedFilesystem | false |
| PluginScriptsLocation | C:\matlab-parallel-slurm-plugin-main |
Customize paths in JobStorageLocation to your preference. Set PluginScriptsLocation to path where you extracted Parallel Computing Toolbox plugin.
- Add additional properties to the AdditionalProperties table:
| Name | Value | Type |
|---|---|---|
| AuthenticationMode | IdentityFile | String |
| ClusterHost | login.devana.nscc.sk | String |
| IdentityFile | C:\Users\user\Documents\MobaXterm\home.ssh\id_rsa | String |
| IdentityFileHasPassphrase | false | Logical |
| RemoteJobStorageLocation | /home/username/matlab | String |
| SSHPort | 5522 | Number |
| UseIdentityFile | true | Logical |
| Username | username | String |
- Click Done to save your cluster profile.
If you need more configuration details click here.
Validate the Cluster Profile¶
Specify the number of workers to use when validating your profile. If you do not specify the number of workers in the Validation tab, then the validation will attempt to use as many workers as the value specified by the NumWorkers property on the Properties tab.
- If it is not already open, start the Cluster Profile Manager from the MATLAB desktop. On the Home tab, in the Environment area, select Parallel > Create and Manage Clusters.
- Select your cluster profile in the listing.
- Click Validation tab.
- Use the check boxes to select all or a subset of the validation stages, and specify the number of workers to use when validating your profile.
- Click Validate.
After the client completes the cluster validation, the Validation tab shows the output.
User guide¶
More information on MPS can be found here. Software documentation and user guide can be found here.