At IU, on Carbonate and Mason, how do I use MATLAB?

Note:
Mason, Indiana University's large memory computer cluster, will be retired on January 1, 2018. For more, see About the Mason retirement.

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

On this page:


Setting 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 Carbonate or Mason, you must first add the matlab module to your user environment. To make sure the matlab module is added every time you log in, add the following line to your ~/.modules file:

  module load matlab

For more about using Modules to configure your user environment, see On the research computing systems at IU, how do I use Modules to manage my software environment?

Submitting a MATLAB batch job

To submit a MATLAB batch job on Carbonate or Mason:

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

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

     #!/bin/bash 
     #PBS -l nodes=1:ppn=1
     #PBS -l walltime=00:10:00
     #PBS -l vmem=8gb
     #PBS -m ae
     #PBS -M username@iu.edu
     #PBS -N matlab_job_name
     #PBS -V
     
     cd /N/u/username/Mason/new_directory
    
     matlab -r matlab_input

    The example script above will:

    • Change the working directory to the directory where the matlab_input.m m-file is located.
    • Have MATLAB run the commands in the matlab_input.m m-file (with the -r option, you can leave off the m-file's .m extension).
    • Have Mason email you when the job is complete.
    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 (i.e., -l nodes=1:ppn=24). This way the scheduler will not stack multiple jobs on a single node and make them compete for available RAM. If you need help or have a question, email the High Performance Systems group.
  3. Submit the script to TORQUE; from the command prompt, enter:
      [username@h1 ~]$ qsub matlab_job
  4. To check the status of your job, use the qstat command (replace username with your IU username):
      qstat -u username

Running 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 Carbonate or Mason command line; for example:

  username@h1 ~]$ module load matlab
  username@h1 ~]$ matlab

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

To run an interactive MATLAB job on Carbonate or Mason:

  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:
      username@h1 ~]$ 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 (i.e., -l nodes=1:ppn=24). This way the scheduler will not stack multiple jobs on a single node and make 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:

      qsub: waiting for job 176424.m1.mason to start
      qsub: job 176424.m1.mason ready
    
      username@Mason: ~>
  3. From the compute node command prompt, enter matlab to launch MATLAB:
      username@Mason: ~>matlab
      Warning: No display specified.  You will not be able to display graphics on the screen.
      Warning: No window system found.  Java option 'Desktop' ignored.
      
                                  < M A T L A B (R) >
                        Copyright 1984-2013 The MathWorks, Inc.
                          R2013a (8.1.0.604) 64-bit (glnxa64)
                                   February 15, 2013
      
      No window system found.  Java option 'Desktop' ignored.
      
      To get started, type one of these: helpwin, helpdesk, or demo.
      For product information, visit www.mathworks.com.
      
      >>

Using the MATLAB GUI

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

Once you've established an SSH connection to Carbonate or Mason 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, as in the above example.
  • 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 On my personal computer, how do I use X forwarding to securely run graphical applications installed on IU's research computing systems?

Getting help

Support for IU research computing systems, software, and services is provided by various UITS Research Technologies units. For help, see Research computing support at IU.

Back to top

This is document bdpj in the Knowledge Base.
Last modified on 2017-07-19 08:44:36.

  • Fill out this form to submit your issue to the UITS Support Center.
  • Please note that you must be affiliated with Indiana University to receive support.
  • All fields are required.

Please provide your IU email address. If you currently have a problem receiving email at your IU account, enter an alternate email address.

  • Fill out this form to submit your comment to the IU Knowledge Base.
  • If you are affiliated with Indiana University and need help with a computing problem, please use the I need help with a computing problem section above, or contact your campus Support Center.

Please provide your IU email address. If you currently have a problem receiving email at your IU account, enter an alternate email address.