MATLAB on Orca
THIS PAGE IS OUT OF DATE!! SEE MATLAB on Graham
There are two ways to run MATLAB on Sharcnet. The first is interactively through orca's development nodes, while the second is as a submitted job. Depending on how the first is used it could be impractical (see Interactively). The second is useful for running a time-consuming script like a diagnostic, or movie making function. Submitted jobs must be configured to run entirely on their own as there is no possibility of manually giving inputs. In any case, you must have a valid Matlab account and have set-up Matlab on sharcnet (see Set-up).
Matlab can also be run on a local machine by remotely mounting Sharcnet. See Remote Mount of Sharcnet on how to do this.
Set-up
After following the directions to get Matlab, a few modifications are necessary.
- Remove the -nojvm and -singleCompThread arguments from the first line so that you are left with
- /opt/sharcnet/local/matlab/R2014a/bin/matlab -nosplash -nodesktop
- Add start-up commands
- That is enough to get Matlab working, but it is also a good idea to run a start-up file to add paths to your workspace and set defaults. Add these commands to
startup.m
, which must exist on the Matlab path (/home/<USER>/Documents/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: maybe change the figure settings). This functionality will also apply to jobs submitted to the Sharcnet queue.
Interactively
There are two ways to run Matlab interactively. Either with X-forwarding or without. The first can be slow for graphics, while the second removes graphic forwarding all-together. The second will probably be the most useful, since figures can be saved and then that file can be transferred to a local machine for viewing. Though this sounds like more work, it is actually faster.
With X-forwarding
- log into orca with X-forwarding (
ssh -X orca.sharcnet.ca
or using a configured ssh command - see ssh config) - log into one of the four development nodes with X-forwarding (
ssh -X orca-dev1
orDevConnect
if the function has been declared). See Accessing Development Nodes for info onDevConnect
which will automatically choose the dev node with the lowest usage. For this reason it should be used over the generic ssh command. - run Matlab (
./uwmatlab
)
Without X-forwarding
- log into orca without X-forwarding (
ssh orca.sharcnet.ca
or using a configured ssh command - see ssh config) - log into one of the four development nodes with X-forwarding (
ssh orca-dev1
orDevConnect
if the function has been declared). See Accessing Development Nodes for info onDevConnect
which will automatically choose the dev node with the lowest usage. For this reason it should be used over the generic ssh command. - run Matlab (
./uwmatlab
) - print figure (the commands
print_figure
orprint_all
are built into the SPINSmatlab package) - scp figure to local machine
Submitted Job
Use the following script to submit a job (it is like the submission 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 - just use the DELAY option. SCRIPT will specify which matlab file will be run.
#!/bin/bash
# bash script for submitting a matlab job to the sharcnet queue
#### Options ####
QUEUE=kglamb
MPP=12g
RUNTIME=2h
DELAY=false
DELAY_FOR=9175185
NAME=diagnostics
SCRIPT=diagnostics.m
#### OTHER INFO ####
DATE=`date +%Y-%m-%d_%H\h%M`
LOG_NAME="mat_${DATE}.log"
#### Submit ####
if [[ -f ${SCRIPT} ]]; then
if [[ "${DELAY}" = false ]]; then
sqsub -q ${QUEUE} \
--mpp=${MPP} \
-r ${RUNTIME} \
-j ${NAME} \
-o ${LOG_NAME} \
-i ${SCRIPT} \
/home/<USER>/uwmatlab
elif [[ "${DELAY}" = true ]]; then
sqsub -q ${QUEUE} \
--mpp=${MPP} \
-r ${RUNTIME} \
-j ${NAME} \
-o ${LOG_NAME} \
-w ${DELAY_FOR} \
-i ${SCRIPT} \
/home/<USER>/uwmatlab
fi
echo "Submitted ${SCRIPT} for matlab."
echo " Requested memory: ${MPP}"
echo " Requested runtime: ${RUNTIME}"
echo " Log file: ${LOG_NAME}"
else
echo "Couldn't find ${SCRIPT} - Try again."
fi