MATLAB on Graham: Difference between revisions

From Fluids Wiki
Jump to navigation Jump to search
(Include directions on using a VNC for running matlab interactively)
m (Change link to new SPINS Matlab tools page)
Line 9: Line 9:
addpath('/work/<USER>/spins/matlab')
addpath('/work/<USER>/spins/matlab')
</syntaxhighlight>
</syntaxhighlight>
or whatever the directory the SPINS matlab files are in. This will allow you to use the built in SPINS commands from any directory. Add other commands you want into this file as well (for example: set default figure settings, or auto-loading of [[SPINS MATLAB plotter| SPINS Matlab]] functions). This functionality will also apply to non-interactive jobs submitted to the regular queue.
or whatever the directory the SPINS matlab files are in. This will allow you to use the built in SPINS commands from any directory. Add other commands you want into this file as well (for example: set default figure settings, or auto-loading of [[SPINS MATLAB tools| SPINS Matlab]] functions). This functionality will also apply to non-interactive jobs submitted to the regular queue.


== Interactive Job ==
== Interactive Job ==

Revision as of 12:24, 31 October 2018

There are two ways to run MATLAB on Graham. The first is interactively through VNC, while the second is as a submitted job. Depending on the speed of your internet connection, it could be impractical to use the first. The second is also useful for running time-consuming scripts like diagnostics, or movie making functions. Submitted jobs must be configured to run entirely on their own as there is no possibility of manually giving inputs.

Set-up

Many details are in Running Matlab on Graham, but the main points are presented here.

It is a good idea to run a start-up file which adds paths to your work space and sets defaults. Add these commands to startup.m, which must exist on the Matlab path (~/matlab should work). If using SPINS, a good command to have in the start-up file is:

addpath('/work/<USER>/spins/matlab')

or whatever the directory the SPINS matlab files are in. This will allow you to use the built in SPINS commands from any directory. Add other commands you want into this file as well (for example: set default figure settings, or auto-loading of SPINS Matlab functions). This functionality will also apply to non-interactive jobs submitted to the regular queue.

Interactive Job

Running Matlab interactively requires the use of a VNC. See VNC on how to set-up and run a VNC.

Once you have the virtual network running, start matlab with these steps:

$ module load matlab/2018a
$ matlab

There are currently (as of May 2018) three matlab versions available: 2016b, 2017a, and 2018a. You can chose which one you want in the module load command.

Submitted Job

Use the following script to submit a job (it is like the submit script for a regular job, but built for matlab). You will need to replace <USER> with your user ID, or replace that line with the location of the matlab run file. This script can be told to wait for another submitted job to complete before running (remove one # from the dependency line, and include the job ID number

#!/bin/bash
# bash script for submitting a Matlab job to the sharcnet Graham queue

#SBATCH --mem-per-cpu=6G        # memory per processor (default in Mb)
#SBATCH --time=01-00:00         # time (DD-HH:MM)
#SBATCH --job-name="A name"     # job name
#SBATCH --input=matlab_test.m   # Matlab script
##SBATCH —dependency=afterok:<jobid>  # Wait for job to complete

#SBATCH --ntasks=1              # number of processors
#SBATCH --output=mat-%j.log                 # log file
#SBATCH --error=mat-%j.err                  # error file
#SBATCH --mail-user=<USER>@uwaterloo.ca     # who to email
#SBATCH --mail-type=FAIL                    # when to email
#SBATCH --account=ctb-mmstastn              # UW Fluids designated resource allocation
module load matlab/2018a 
srun matlab -nodisplay -nosplash -singleCompThread