Configuration and setup for MATLAB

Note: This section describes MATLAB 2019b and later and assume you are logged in with ThinLinc.

The initial cluster configuration step will create a Cluster called kebnekaise where jobs can run using the batch system instead of submitting them to the local machine.

Cluster configuration MATLAB 2019

  1. Start MATLAB, either
    • Using the menus to start a Matlab for you: Applications → Programming → Matlab
    • Select a specific version of MATLAB from those installed by starting it from the ThinLinc Linux terminal:
      • Start a Linux terminal: Application → System Tools → MATE Terminal
      • Type the following to find the version
        module spider MATLAB
        
      • Load the desired version, here 2019b
        module load MATLAB/2019b.Update2
        
      • Start MATLAB
        matlab -singleCompThread
        
  2. Inside the MATLAB command window, run the following command and select the Kebnekaise option:
    configCluster.sh
    

Cluster configuration MATLAB 2021 and later

The configuration have to be done in a Linux terminal.

  1. Select a specific version of MATLAB from those installed by starting it from the ThinLinc Linux terminal:
    • Start a Linux terminal: Application → System Tools → MATE Termina l
    • Type the following to find the version
      module spider MATLAB
      
    • Load the desired version, in this example, 2023a
      module load MATLAB/2023a.Update4 
      
  2. Once the MATLAB module is loaded for the version you need, run the following script on the Kebnekaise terminal:
    configCluster.sh
    

Job settings configuration

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.

  1. Start a MATLAB session, if you have not already. Do this either from the menu, or from a terminal:
    • From the menu: Application → Programming → Matlab
    • From a terminal:
      • Start a Linux terminal: Application → System Tools → MATE Termina l
      • Load the desire MATLAB version, here 2023a
        module load MATLAB/2023a.Update4
        
      • Start MATLAB
        matlab -singleCompThread
        
  2. Now type in the MATLAB command window.
  3. First get a handle to the cluster:
    c = parcluster('kebnekaise');
    
  4. Specify account name (i.e., the project ID in the form hpc2nXXXX-YYY) and the requested walltime (these are required):
    c.AdditionalProperties.AccountName = 'account-name';
    c.AdditionalProperties.WallTime = 'HHH:MM:SS';
    
  5. Other generic properties that can be set (are not required):
    • Specify cores per node:
      c.AdditionalProperties.ProcsPerNode = <num-cores>;
      
    • Constraints (type of node, CPU, GPU, etc.):
      c.AdditionalProperties.Constraint = 'feature'; 
      
      To see possible features, check the Requesting specific features section.
  6. Save the profile
    c.saveProfile
    
  7. In order to list the content of your profile, you can always do c.AdditionalProperties.
  8. To clear a value, assign the property an empty value (‘’, [], or false). Example:
    c.AdditionalProperties.Constraint = ‘’;
    

Job settings in the Cluster Profile Manager

You can change the job settings (or make them all together) inside the GUI. To do that, you change the job settings within the Cluster Profile Manager.

You can view, edit, and/or add to the default profile by clicking the “Parallel” menu icon and selecting “Create and Manage Clusters”.

matlab-parallel.png

cluster-profile.png

If you scroll down in the window that appears when you select the right cluster, you will see a box titled “Scheduler Plugin”. This box lets you set SBATCH parameters like

  • Your account name (project name),
  • Your email address,
  • Constraints,
  • The number of processes per node (ProcsPerNode),
  • GpusCard,
  • GpusPerNode,
  • The wall time for your job,
  • etc.

Click “edit” in the lower right corner to be able to edit the values.

editing-parameters.png

Click “Done” when you have edited the values.

In other words, almost anything you might otherwise set by calling c.AdditionalProperties.=… can be set in the GUI in this scheduler plugin. Just keep in mind that these settings are saved between sessions.

GPU aware jobs

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

Example

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

c.AdditionalProperties.Constraint = 'l40s';
c.AdditionalProperties.GpusPerNode = 1;

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

c.AdditionalProperties.Constraint = 'v100';
c.AdditionalProperties.GpusPerNode = 2;

Note

Remember to always save the changes after modifying any of the fields:

c.saveProfile

For full documentation about using GPUs please read MathWorks GPU Computing.

Warning

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 and save the profile:

c.AdditionalProperties.Constraint = '';
c.AdditionalProperties.GpusPerNode = '';
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.