ARCHIVED: Use MATLAB on Karst at IU

This content has been archived, and is no longer maintained by Indiana University. Information here may no longer be accurate, and links may no longer be available or reliable.

On this page:


Overview

On Karst 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 on one of Karst's interactive nodes. You also can use the MATLAB graphical user interface (GUI) for interactive sessions by connecting to Karst using SSH with X forwarding enabled.

Set up your user environment

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

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

module load matlab

Submit a MATLAB batch job

To submit a MATLAB batch job on Karst:

  1. Create an m-file (for example, matlab_input.m) containing the commands MATLAB should run.
  2. Create a job script (matlab_job) for the TORQUE resource manager on Karst.

    For example (replace username with your IU username and username@iu.edu with your IU email address):

    #!/bin/bash
    #PBS -l nodes=1:ppn=16,walltime=1:00:00
    #PBS -M username@iu.edu
    #PBS -m abe 
    #PBS -N JobName
    #PBS -o matlab_output
    #PBS -e matlab_error
    
    cd /N/u/username/Karst/new_directory
    
    matlab < matlab_input.m
    

    The above example script will:

    • Request one hour of time for your job.
    • Change the working directory to the directory where the matlab_input.m m-file is located.
    • Have MATLAB run the commands in matlab_input.m.
    • Have Karst email you when the job is complete.
  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

You can run a short interactive MATLAB session from the command line on the login nodes; however, if your session will require more than 20 minutes of processor time, you must run an interactive job on a compute node.

  • To run a quick interactive session on a login node, load the matlab module, and then launch MATLAB from the command line; for example:
    [username@h2 ~]$ module load matlab
    [username@h2 ~]$ matlab
    
  • To run an interactive session on a compute node, first use the qsub command with the -I (interactive) option to submit a job request to Karst's interactive queue (-q interactive). When your job is ready and you are placed on a compute node, load the matlab module, and then launch MATLAB; for example:
    [username@h2 ~]$ qsub -I -q interactive -l nodes=1:ppn=1,walltime=1:00:00
    qsub: waiting for job 371037.m2 to start
    . . . 
    [username@c5 ~]$ module load matlab
    [username@c5 ~]$ matlab
    

Use the MATLAB GUI

To use the MATLAB graphical user interface (GUI), you must enable X forwarding in your SSH client's connection settings for Karst. Also, before connecting via SSH to Karst, you must have an X server program (for example, Xming for Windows or XQuartz for macOS) running on your local computer. (For complete instructions, see Use X forwarding on a personal computer to securely run graphical applications installed on IU's research supercomputers.)

Once you have an SSH connection to Karst (with X forwarding enabled):

  • For a quick session, load the matlab module and launch MATLAB (as described in previous section).
  • For a session requiring more than 20 minutes of processor time, use qsub to submit a job request to Karst's interactive queue (as described in the previous section).
    Note:
    You must add the -X option to your qsub command to enable X forwarding.

    When your job is ready and you are placed on a compute node, load the matlab module, and then launch MATLAB; for example:

    [username@h2 ~]$ qsub -I -X -q interactive -l nodes=1:ppn=1,walltime=1:00:00
    qsub: waiting for job 371037.m2 to start
    . . .
    [username@c5 ~]$ module load matlab
    [username@c5 ~]$ matlab
    

Get help

If you need help or have questions regarding the use of MATLAB on IU's research supercomputers, contact the UITS Research Applications and Deep Learning team.

Research computing support at IU is provided by the Research Technologies division of UITS. To ask a question or get help regarding Research Technologies services, including IU's research supercomputers and research storage systems, and the scientific, statistical, and mathematical applications available on those systems, contact UITS Research Technologies. For service-specific support contact information, see Research computing support at IU.

This is document ayfu in the Knowledge Base.
Last modified on 2023-05-09 14:44:11.