Use MATLAB on Karst or Carbonate at IU

On this page:


Overview

On Karst or Carbonate at Indiana University, you can use MATLAB interactively from the command line on the login nodes, or in batch mode using a TORQUE script to submit a job to the compute nodes. If your interactive session will require more than 20 minutes of processor time, you must run it as an interactive job on one of Karst or Carbonate's compute nodes. You also can use the MATLAB graphical user interface (GUI) for interactive sessions by using SSH with X forwarding enabled.

Set up your user environment

On the research computing resources at Indiana University, the Modules environment management system provides a convenient method for dynamically customizing your software environment.

To use MATLAB on Karst or Carbonate, you first must add the matlab module to your user environment. To make sure the matlab module is added every time you log in, you can add the following line to your ~/.modules file:

module load matlab

For more about using Modules to configure your user environment, see Use Modules to manage your software environment on IU's research computing systems.

Submit a MATLAB batch job

To submit a MATLAB batch job on Karst or Carbonate:

  1. Create an m-file (also known as a script file) containing the commands MATLAB should run, and then save it with a .m extension (for example, matlab_input.m).
  2. Create a TORQUE batch job script that specifies the application you want to run and the resources required to run it.

    For example:

    #!/bin/bash 
    #PBS -l nodes=1:ppn=1
    #PBS -l walltime=01:00:00
    #PBS -l vmem=8gb
    #PBS -m abe
    #PBS -M my_email@iu.edu
    #PBS -N matlab_job_name
    #PBS -V
     
    cd /path/to/your/m-file
    
    matlab -r matlab_input
    

    In the above example:

    -l nodes=1:ppn=1 Requests one processor on one node. If you are running multiple jobs, you should request the full number of processors per node (16 on Karst; 24 on Carbonate); otherwise, the job scheduler may stack multiple jobs on a single node and make them compete for available RAM.
    -l walltime=01:00:00 Requests one hour of wall-clock time for your job
    -l vmem=8gb Requests 8 GB of virtual memory
    -m abe Sends email if the job is (a) aborted, when it (b) begins, and when it (e) ends
    -N matlab_job_name Names the job matlab_job_name
    -M my_email@iu.edu Sends you job-related email (replace my_email@iu.edu with your IU email address)
    cd /path/to/your/m-file Changes the working directory to the directory where your m-file is located. Depending on the system
    matlab -r matlab_input Makes MATLAB run the commands in your m-file (matlab_input.m); with the -r option, you can leave off the m-file's .m extension
  3. Submit the script to TORQUE; from the command prompt, enter:
      qsub matlab_job
  4. To check the status of your job, use the qstat command (replace username with your IU username):
      qstat -u username

Run MATLAB interactively

Note:

If your interactive session will require less than 20 minutes of processor time, you can load the matlab module and launch the application from the Karst or Carbonate command line.

Interactive sessions requiring more than 20 minutes of processor time must be submitted as interactive jobs to compute nodes on Karst or Carbonate. This method of interactive execution is strongly recommended, as the login nodes on either system are not intended for computational work.

To run an interactive MATLAB job on Karst or Carbonate:

  1. Make sure your user environment is configured properly; see Setting up your user environment above.
  2. From the command line, enter the qsub command with the -I (interactive) flag added; for example:
      qsub -I -l walltime=01:00:00 -l nodes=1:ppn=1 -l vmem=8gb 
    Note:
    This example requests a single core on a single processor. If you are running multiple jobs, you should request the full number of processors per node (16 on Karst; 24 on Carbonate) to prevent the scheduler from stacking multiple jobs on a single node and making them compete for available RAM. If you need help or have a question, email the High Performance Systems group.

    When the resources needed to run your job are available, your job will start, and then you will be placed on a compute node.

  3. From the compute node command prompt, enter matlab to launch MATLAB.

Use the MATLAB GUI

You can use the MATLAB graphical user interface (GUI) in interactive sessions on Karst or Carbonate's login and compute nodes. To do so, you must enable X forwarding in your SSH client's connection settings. Additionally, you must have an X server program (such as Xming for Windows or XQuartz for macOS) running on your local computer before connecting via SSH with X forwarding enabled.

Once you've established an SSH connection to Karst or Carbonate with X forwarding enabled:

  • To use the MATLAB GUI for an interactive session on a login node, load the matlab module, and then launch MATLAB from the command line.
  • To use the MATLAB GUI for an interactive job on a compute node, use the qsub command with the -I (interactive) and -X (X forwarding) switches added; for example:
      qsub -I -X -l walltime=02:00:00 -l nodes=1:ppn=1 -l vmem=8gb

For instructions on setting up and using X forwarding, see Use X forwarding on a personal computer to securely run graphical applications installed on IU's research computing systems

Get help

If you need help or have a question about using MATLAB on IU's research supercomputers, contact the UITS Research Applications and Deep Learning team.

Support for IU research computing systems, software, and services is provided by the Research Technologies division of UITS. To ask a question or get help, contact UITS Research Technologies.

This is document bdpj in the Knowledge Base.
Last modified on 2019-04-24 11:54:53.

Contact us

For help or to comment, email the UITS Support Center.