Configure and setup of MATLAB 2019b and later

This section describes MATLAB 2019b and later.

Unless Matlab graphical interface is already started, start it using one of the following methods:

  • Using the menus to start a Matlab for you:  Application → HPC2N Applications → Applications → Matlab .... 
  • but you can also select a specific version of MATLAB from those installed by starting it from the ThinLinc linux terminal:
Check for available versions
module spider matlab
# Select required version
# Since different versions of MATLAB differ in user configuration it is important to specify which version to use
module load MATLAB/2019b.Update2
matlab -singleCompThread

To be able to use MATLAB 2019b, and later, together with the batch system, MATLAB needs to be configured to use a cluster profile.
This needs to be done only once for each cluster and each version of MATLAB.

Cluster configuration MATLAB 2019

When MATLAB is started, run the following script on the MATLAB command window and select the Kebnekaise option:

configCluster.sh

Cluster configuration MATLAB 2021 and later

Once the MATLAB module is loaded for the version you need, run the following script on the Kebnekaise terminal:

configCluster.sh

This initial step will create a Cluster called kebnekaise where jobs can run using the batch system instead of submitting them to the local machine. But before we can submit jobs, some additional properties need to be set for each MATLAB version (account to use, requested walltime, etc). Any parameters specified using the below workflow will be persistent between MATLAB sessions.

Job configuration

Start a MATLAB session (matlab -singleCompThread). First get a handle to the cluster:

c = parcluster('kebnekaise');

Specify account name (i.e., the project ID in the form hpc2nXXXX-YYY, SNICXXX-YY-ZZ, or NAISSXXXX-YY-ZZ) and requested walltime (these are required):

c.AdditionalProperties.AccountName = 'account-name';
c.AdditionalProperties.WallTime = '05:00:00';

Other generic properties that can be set are (not required):

  • QueueName - To use the nodes with more memory use "largemem" on Kebnekaise, this is necessary for using Large Memory nodes.
  • EmailAddress
  • RequireExclusiveNode

GPU aware jobs

If your job has routines that are GPU aware, you can also specify additional GPU properties:

  • GpuCard - v100
  • GpusPerNode - use 1 or 2
  • AdditionalSubmitArgs 
  • ActivateMultiProcessServiceForGpus
  • RequireExclusiveGpu

Example:

If you want to request 1 GPU card these options would do the work:

c.AdditionalProperties.GpuCard = 'v100';
c.AdditionalProperties.GpusPerNode = 1;

If you want to request 2 GPU cards (whole node) these options should work:

c.AdditionalProperties.GpuCard = 'v100';
c.AdditionalProperties.GpusPerNode = 2;
c.AdditionalProperties.AdditionalSubmitArgs = '--exclusive';

For full documentation about using GPUs please read MathWorks GPU Computing

To see the values of the current configuration options, call the specific AdditionalProperties name.

c.AdditionalProperties

To clear a value, assign the property an empty value (‘’, [], or false).

c.AdditionalProperties.EmailAddress = ‘’;

Save changes after modifying AdditionalProperties fields.

c.saveProfile

Note: If you set the GPU values in your Cluster profile all the jobs that you submit through this profile will allocate GPU resources even though they aren't GPU aware. Thus, if you initially set the GPU values and for your current workflow you won't be using them, you can reset these values as follows: 

Start a MATLAB session and get a handle to the cluster:

c = parcluster('kebnekaise');

now, reset the values:

c.AdditionalProperties.GpuCard = '';
c.AdditionalProperties.GpusPerNode = '';
c.AdditionalProperties.AdditionalSubmitArgs = '';
c.saveProfile

Cluster validation

MATLAB has a built-in function to check if the Cluster profile was set properly. In the MATLAB GUI, navigate to HOME → Parallel → Create and Manage Clusters and select the option called kebnekaise in the Cluster Profile. Click on the tab called "validation" and set the "Number of workers to use" to 4 for instance. After this click on the "Validate" button. If the cluster is well configured, all the "Status" results should show a "passed" result in green. 

Updated: 2024-10-10, 12:39