Configure for Slurm, Torque, LSF, PBS, Grid Engine, HTCondor, or AWS Batch
Use MATLAB® Parallel Server™ with third-party schedulers to run parallel jobs on your cluster. This configuration allows MATLAB clients to submit jobs to clusters managed by schedulers such as Slurm, LSF® and Torque.
Before you start, you must ensure that you have installed and licensed MATLAB Parallel Server on your cluster nodes. For details, see License and Install MATLAB Parallel Server in Cluster.
How MATLAB Interfaces with Third-Party Scheduler Clusters
MATLAB Parallel Server does not require server-side components or a dedicated service on your cluster. Instead, MATLAB uses a plugin framework with scripts that define how the MATLAB client communicates with the scheduler and MATLAB Parallel Server workers.
Each MATLAB installation with Parallel Computing Toolbox™ includes scheduler-specific plugin scripts that you can use directly or customize. The plugin scripts contain instructions tailored to your cluster infrastructure, such as:
How to interface with the job scheduler (submit, monitor, or cancel jobs).
How to transfer job and task data to cluster nodes.
Cluster profiles let you define certain properties for the plugin scripts, then have these properties applied when you create cluster, job, and task objects in the MATLAB client. By default, your MATLAB installation comes with plugin scripts and cluster profile templates for these schedulers:
Slurm
LSF
Torque
PBS Pro® and OpenPBS
Grid Engine
HTCondor
AWS® Batch
If you are using a scheduler that is not supported by MATLAB, you can use the generic scheduler interface. To interface with a cluster using the Generic cluster profile, see Configure Using the Generic Scheduler Interface.
To manage jobs, the scripts call scheduler command-line utilities. For example,
sbatch, qsub, or bsub
to submit jobs and squeue, qstat, or
bjobs to query job status. To enable communication between
the client and MATLAB
Parallel Server workers, the scripts store job and task files on disk for transfer and
result retrieval.
Run Jobs from Computers with Scheduler Utilities and Shared File
System
Run Jobs on Remote Clusters or Clusters Without Shared File System
Create Cluster Profile and Validate Installation
Create a cluster profile for your specific scheduler. This procedure verifies that the parallel computing products are installed and configured correctly on your cluster.
For some schedulers, you can create a cluster profile using either a built-in cluster type or the generic scheduler interface. As a best practice, use built-in cluster types where possible.
Step 1: Create a Cluster Profile
In this step you create a cluster profile to use in subsequent steps.
On a MATLAB client, 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 (or AWS Batch, Grid Engine, HTCondor, LSF, or PBS Pro, or Torque as appropriate).
With the new profile selected in the list, click Rename and edit the profile name to be
InstallTest. Select Enter.In the Properties tab, provide settings for the following fields:
Set the Description field to
For testing installation.Set the JobStorageLocation field to the location where you want to store job and task data on the client computer, for example,
C:\Temp\joblocation. If this location is also accessible from nodes on the cluster, MATLAB Parallel Server workers can read and write to it directly. Otherwise, the client usessftpto copy job and task data files to and from the cluster.Note
You must not use the same job storage location for different versions of parallel computing products. Each version on your cluster must use its own job storage location.
Set the NumWorkers field to the number of workers you want to run the validation tests on, within the limitation of your licensing.
Set NumThreads to the number of threads to use on each worker.
Set the ClusterMatlabRoot to the location of the MATLAB installation to run on the worker machines.
If the cluster uses online licensing, set RequiresOnlineLicensing to true.
If you set RequiresOnlineLicensing to true, in the LicenseNumber field, enter your license number.
If you are using LSF, set the OperatingSystem field to the operating system of your worker machines.
Set the HasSharedFilesystem field to
trueif the client and workers share a file system and can use the sameJobStorageLocationfolder. Otherwise, set HasSharedFilesystem to false. Then add theRemoteJobStorageLocationproperty to the AdditionalProperties table and set its value to a folder on the cluster that the head node and workers can access.When HasSharedFilesystem is false, MATLAB uses SFTP to move job and task files between the client and the cluster.
By default, your MATLAB installation comes with scheduler plugin scripts that are ready to use. You can leave the PluginScriptsLocation field to the default MathWorks® provided plugin scripts.
If you want to use customized plugin scripts in the cluster profile, you can specify the location of the customized plugin scripts in the PluginScriptsLocation field. To learn how to download and modify the default plugin scripts, see Download and Customize Plugin Scripts.
You can add additional properties to the AdditionalProperties table to customize how the client interacts with the cluster using built-in scheduler properties or custom scheduler properties. For a full list of built-in additional properties for each scheduler, see Customize Behavior of Sample Plugin Scripts.
For example, you can use these additional properties to connect and run jobs on a remote cluster.
ClusterHostIf the client does not have access to scheduler utilities to directly submit jobs to the scheduler, the plugin scripts create an SSH session to the cluster and run scheduler commands over that connection. As MATLAB runs scheduler utilities such as
sbatchandsqueue, you must provide the hostname of the cluster head node or login node. Under the AdditionalProperties table, select Add. Specify a new property with nameClusterHost. For the value, specify the hostname of the cluster head node, for example,cluster-host-name. Set Type toString.RemoteJobStorageLocationIf the client and workers do not share the same job storage location, and you set HasSharedFilesystem to false, you must provide a job storage location that the head node and cluster workers can access. The client copies job and task files between your computer and the remote job storage location on cluster using SFTP. Under the AdditionalProperties table, select Add. Specify a new property with name
RemoteJobStorageLocation. For the value, provide the path to a location that the cluster workers can store jobs and task data, for example/network/share/joblocation. Set Type toString.
Click Done to save your cluster profile. The completed cluster profile should look something like one of these figures.
Step 2: Validate the Cluster Profile
In this step you verify your cluster profile, and thereby your installation.
You can 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. You can specify a
smaller number of workers to validate your configuration without occupying the
whole cluster.
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.
This figure shows the results of the InstallTest
profile that passed all validation tests.
Note
If your validation does not pass, contact the MathWorks install support team.
If your validation passed, you now have a valid profile that you can use in
other parallel applications. You can make any modifications to your profile
appropriate for your applications, such as NumWorkersRange,
AttachedFiles, AdditionalPaths, and so
on.
To share your profile for other users, select the profile and click Export, then save your profile to a file in a convenient location. Other users can import your profile by selecting Import in the Cluster Profile Manager.
Download and Customize Plugin Scripts
Parallel Computing Toolbox uses a set of plugin scripts to define how your machine communicates with your scheduler. Your MATLAB installation comes with scheduler specific plugin scripts that are ready to use. However, you can download and modify the plugin scripts to configure how MATLAB interacts with the scheduler to best suit your cluster setup and support custom submission options.
Download Plugin Scripts
MathWorks provides plugins for the following third-party schedulers, which you can download from GitHub® repositories or the Add-On Explorer.
| Plugin | GitHub Repository |
|---|---|
Parallel Computing Toolbox plugin for MATLAB Parallel Server with Slurm | https://github.com/mathworks/matlab-parallel-slurm-plugin |
Parallel Computing Toolbox plugin for MATLAB Parallel Server with IBM Spectrum® LSF | https://github.com/mathworks/matlab-parallel-lsf-plugin |
Parallel Computing Toolbox plugin for MATLAB Parallel Server with Grid Engine | https://github.com/mathworks/matlab-parallel-gridengine-plugin |
Parallel Computing Toolbox plugin for MATLAB Parallel Server with PBS | https://github.com/mathworks/matlab-parallel-pbs-plugin |
Parallel Computing Toolbox plugin for MATLAB Parallel Server with HTCondor | https://github.com/mathworks/matlab-parallel-htcondor-plugin |
Use either of these workflows to download the appropriate plugin scripts for your scheduler.
You can download the plugins from a GitHub repository.
Clone the GitHub repository from a command windows on your machine. For example, to clone the repository for the Parallel Computing Toolbox plugin for MATLAB Parallel Server with Slurm, use:
git clone https://github.com/mathworks/matlab-parallel-slurm-plugin
Visit the GitHub page in a browser and download the plugin as a ZIP archive.
Alternatively, to install the add-ons from the MATLAB Add-On Explorer, go to the Home tab and, in the Environment section, click the Add-Ons icon. In the Add-On Explorer, search for the add-on and install it.
You can also download the plugins from MATLAB Central™ File Exchange.
Customize Plugin Scripts
You can customize the plugin scripts by adding your own custom additional properties. Custom additional properties allow you to modify the values for these properties when you submit jobs to the cluster without having to repeatedly modify the plugin scripts.
As an example, consider a Slurm scheduler. The submit command for Slurm
accepts a -nodelist argument that allows you to specify the
nodes you want to run on. Creating an additional property for the
-nodelist allows you to change the value of this argument
without modifying your plugin script. To create the -nodelist
argument additional property, include this code pattern in either your
independentSubmitFcn.m or
communicatingSubmitFcn.m script in the plugin script
folder.
% Basic SLURM submit command submitCommand = 'sbatch'; % Check if property is defined if isprop(cluster.AdditionalProperties, 'NodeList') % Add appropriate argument and value to submit string submitCommand = [submitCommand ' --nodelist=' cluster.AdditionalProperties.NodeList]; end
Alternatively, to modify the submit command for both independent and
communication jobs, include the code pattern above in your
getCommonSubmitArgs function. The
getCommonSubmitArgs function is a helper function
included in the sample plugin scripts that you can use to modify the submit
command for both types of jobs. You can add custom additional properties to the
AdditionalProperties table in
the cluster profile just like built-in additional properties. You can also set
custom additional properties using the cluster object. To learn more, see Set Additional Properties.
Configure LSF Scheduler on Windows Cluster
If your cluster is already set up to use mpiexec and smpd, you can use Parallel Computing Toolbox with your existing configuration if you are using a compatible MPI
implementation library (as defined in
matlabroot\toolbox\parallel\mpi\mpiLibConf.m).
However, if you do not have mpiexec on your cluster and you want to use it, you can
use the mpiexec software shipped with the parallel computing products.
For further information about mpiexec and smpd, see the MPICH home page. For user’s guides and installation instructions on that page, select Documentation > User Docs.
Configure Windows Firewalls on Server
If you use Windows firewalls on your cluster nodes, add MATLAB to the firewall rules on each node.


