MATLAB on Graham: Difference between revisions
(Include directions on using a VNC for running matlab interactively) |
m (Update interactive matlab) |
||
(One intermediate revision by the same user not shown) | |||
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 | 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 == | ||
Line 15: | Line 15: | ||
Running Matlab interactively requires the use of a VNC. See [[Graham Tips#VNC|VNC]] on how to set-up and run a VNC. | Running Matlab interactively requires the use of a VNC. See [[Graham Tips#VNC|VNC]] on how to set-up and run a VNC. | ||
Once you have the virtual | Once you have the virtual desktop running, start matlab with these steps: | ||
<syntaxhighlight> | <syntaxhighlight> | ||
$ module load matlab/ | $ module load nixpkgs | ||
$ module load matlab/2018b | |||
$ matlab | $ matlab | ||
</syntaxhighlight> | </syntaxhighlight> | ||
There are | There are multiple version of Matlab to chose from. <code>module spider matlab</code> will give you information on what is available. | ||
== Submitted Job == | == Submitted Job == |
Latest revision as of 18:40, 7 March 2019
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 desktop running, start matlab with these steps:
$ module load nixpkgs
$ module load matlab/2018b
$ matlab
There are multiple version of Matlab to chose from. module spider matlab
will give you information on what is available.
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