Running MATLAB on hopper

Configuring Matlab requires a graphical interface.  Please follow the instructions for accessing using Xming or MobaXterm here.

Add the Matlab 2016 module:

module load matlab/2016a

Launch Matlab with the command:  

matlab &

  • At this time if you run any Matlab code, it will be running on head node which is not desired
  • You must configure your parallel computing toolbox in order to run your job on multiple nodes
  • Your code must also be parallel (e.g. using the parallel for-loop command parfor) in order to take advantage of multi-processors
  • Running sequential code on multiple processors does not help computation.  It is identical to running a job on a single processor

Configuring Parallel Computing Toolbox

  • In your terminal window, create a folder for yourself in the scratch area:

mkdir /scratch/your_username

  • In Matlab. click on Parallel and Manage Cluster Profiles

Parallel - Manage Cluster Profiles

  • Select Add > Custom > Torque
  • Click the Edit button in the lower right corner of the TorqueProfile
  • Fill the blanks in Scheduler tab as follows:


Torque Profile


Torque - Files and Folders


Torque - Additional Properties

  • Click the Done button
     
  • Click on the Validation Results tab and click the Validate button:

Torque - Validation

  • Once all the stages are validated successfully, close the window and make sure that your default configuration is Torque.  In the Cluster Profile Manager window, select the TorqueProfile you created and then click the "Set As Default" button in the toolbar.

Important Notes**

  • Now you are ready to go and it will be your default configuration
  • You only need to pass this validation one time
  • When you run your parallel code, it will use this configuration (1 node and 16 processor)
  • If you want more processor and worker, you need to validate it again with the desired value
  • It is recommended that try using 4-10 processors, if not satisfied try using 10-15 processors and so on and see if the performance is increased or decreased
  • For more information about parallel computer with Matlab visit:

http://www.mathworks.com/products/parallel-computing/

http://www.mathworks.com/access/helpdesk/help/toolbox/distcomp/

https://computing.llnl.gov/tutorials/parallel_comp/

  • Running sequential code on multiple nodes won't help you in anyway, it will just simply run on 1 single high speed processor with high memory.
  • It is recommended to ask for nodes=1:ppn=1 if you wish to run sequential program in cluster computer

Matlab Job Submission

Once you validated your parallel computing toolbox, jobs can be submitted in two different ways

  • Graphical User Interface mode-In this case you need to invoke matlab by "matlab &" and run a parallel job the way you usually run job in your local machine but you need to keep your computer open and Matlab running all the time.
  • Batch mode-You can submit your job using a shell script file and check the results later. Meanwhile you can terminate your secureCRT connection and turn off your machine. It is highly recommended to submit the job in batch mode.

In the next section we will go through in details of submitting jobs

GUI mode

  • Notice that parpool open is used to open 16 cores at the beginning of the code
  • datestr(now) is used to print timestamp to measure the time it required for simulation
  • Notice that the inner loop is parfor (parallel for loop), for every sequential (j=1 to 12) iteration, there will be 16 parallel iteration (i=1 to 16)
  • print -djpeg aplotted is a .jpeg file that will save your plot

Sample Parallel Code

  • Job was assigned to 16 labs
  • Give a "showq" in secureCRT terminal and you'll see your job is running in 16 processors

gui3

Batch Mode

  • You need a script file like this

           mat.sh

Matlab Batch Script Example

  • Notice that it requests 16 nodes
  • Walltime 50:00:00 means your job will be killed automatically if it is not finished within 50 hours
  • #PBS -o default.out is your default output file unless you specify any other output file
  • #PBS -e errorfile is your default error file, any error generated in your Matlab interactive command prompt will be redireted here
  • In the last line it is invoking mywave.m and output (that will be generated in Matlab interactive command window) will be redircted to mywave.out

Using qsub

  • Once you have your script file, make sure that it is executable (you can see it by ls -lrt and you'll see something like rwx-), x stands for executable.  You can make your script file executable with the command chmod 744 file_name.sh

#!/bin/bash

#PBS -l nodes=1:ppn=16,walltime=50:00:00

#following 2 line ensures you'll be notified by email after job completion

#PBS -M au_user_id@auburn.edu

#PBS -m e

#PBS -o default.out

#PBS -e errorfile

/tools/licensed/matlab-2016a/bin/matlab -nodisplay -nosplash  < mywave.m > mywave.out

Write a file (for writing a file in linux, use the nano editor:

  • nano mat.sh
  • Save the file inside the nano editor with Control + X
  • Change permissions on the script file:   chmod 755 mat.sh
  • Submit the job using: qsub ./mat.sh

 

qsub2

You can see the job running by showq. You can terminate your session (by typing "exit") and check back (login) later to see if your job is finished. You no longer need to keep the secureCRT connection.