Caltech Home > Caltech HPC Homepage > Documentation > FAQ > Setting up Matlab to use the Distributed Compute Engine
Search open search form

Setting up Matlab to use the Distributed Compute Engine

Note: The following is the correct procedure for Matlab 2019a, newer versions require a slightly different method. See end of this page for procedure. 

To use the distributed compute engine in Matlab, it is easiest to open the GUI from within Open OnDemand.  You may find out more about using Open OnDemand here.

If you  open the desktop, open a terminal within the desktop, load the Matlab 2019a module, then launch matlab:

module load matlab/r2019a
matlab

You can also use the Matlab application from within on demand if you prefer.  Make sure to specify Matlab 2019a if you do.

Once Matlab is opened up, click on "Environment", Then on "Parallel", and choose "Create and Manage Clusters..."

Matlan DCE environment menu














From the next menu, click "Add Cluster Profile" and select "Slurm"

Matlab DCE select Slurm










Once you select this, you will get a warning message about having access to the software.  Click "OK".  You can also check the "Do not show this message again" checkbox if you like.

Matlab DCE software warning








This will create a new profile.  Typically it is called "SlurmProfile1" but could be something else if you have tried this before.  If you would like, you can double click on the name and rename it to something more appropriate.

Click on the "Edit" Button in the window to be able to edit the cluster.

The most important fields to fill out are the Description, Numworkers, and SubmitArguements.

Description is just a descriptive name for the configuration.  I use "Central Cluster"

NumWorkers is the number of cores you want to be able to use on the cluster from matlab.  The maximum is 512, but it is almost always a better option to choose something smaller like 64 unless you job really requires it. More cores will mean a longer wait time and a higher cost for the run typically.

SubmitArguements is needed to set the wallclock time which is required by the scheduler.  For a 24 hour runtime, type "-t 24:00:00" into the box.  The longest you can run on the cluster for a typical job is 7 days.

Configuring Matlab DCE cluster














Click "Done" when you have finished that, then click on the "Validate" Tab.

The validation will run through the configuration submitting short jobs and making sure it works as expected. If you experience a failure on this validation you may copy the Report output and submit a ticket to the Help system. 

Validating Configuration






Matlab R2020+

The procedure above works for R2019, however newer versions do not provide the "Additional Slurm Properties" field. In this case, follow the existing instructions above, adding the required Slurm parameters to "Scheduler Plugin > AdditionalProperties" key/value fields instead of the "Additional Slurm Properties" field. 

Add an entry for the following to the AdditionalProperties field, set to type:String then click Done. 

Name:
AdditionalSubmitArgs

Value:
--time=12:00:00 --nodes=1

The example settings above will provide twelve hours of compute time on a since node. --node was included in this example as matlab tends to distribute cores amongst multiple nodes which could potentially slow some jobs. There may be other AdditionProperties setting to encourage Matlab to group cores on single nodes.