1/22/2017 - 12:44 AM

MATLAB on sherlock

MATLAB on sherlock

Here is an easy to make files/directories easily accessible on a local machine.

How to mount sherlock directories locally All you have to do mount_sherlock to have access to sherlock directories at your fingertips at a local directory $SHERLOCK/

        |-- .
        |-- home/
        |-- scratch/

If you need to reconnect after getting disconnected, first unmount using unmount_sherlock and then mount again.

Requirements & Setup

  • Be sure to have valid sherlock login credentials using kinit.
  • Install OSXFuse and sshfs
  • Modify your ~/.bashrc with the following environment variables and alias commands

Step 1: Create environment variables that store your sherlock directory paths, and where you want to mount sherlock locally

# Local mount points. Create this directory if it doesn't exist
export SHERLOCK=/path/to/Sherlock

# Make these once and for all 
mkdir $SHERLOCK/home
mkdir $SHERLOCK/scratch

# Directories on Sherlock. Replace <username> and <groupname> appropriately
export SHERLOCK_HOME = /home/<username>
export SHERLOCK_SCRATCH = /scratch/PI/<groupname>/<username>

Step 2: Now make an alias containing mount and unmount commands in your ~/.bashrc

alias mount_sherlock="sshfs sherlock:$SHERLOCK_HOME $SHERLOCK/home; sshfs $SHERLOCK_SCRATCH $SHERLOCK/scratch;"
alias umount_sherlock="umount $SHERLOCK/home; umount $SHERLOCK/scratch;"

If you have followed instructions provided by Research Computing and still failed to successfully call matlab. Make the following changes and try again.

vi ~/.bashrc

Add the following lines to your ~.bashrc file on sherlock 1

module load jre
export MATLAB_JAVA=/share/sw/free/jre/jre1.8.0_91/
module load matlab/R2016b
alias start_matlab='unset _JAVA_OPTIONS ; matlab -nodesktop -nosplash -nodisplay

For sherlock 2

module load java
export MATLAB_JAVA=/share/software/user/open/java/1.8.0_131/jre
module load math
module load matlab/R2017a
alias start_matlab='unset _JAVA_OPTIONS ; matlab -nodesktop -nosplash -nodisplay

Now you are ready to try this

ssh -X sherlock
# For interactive dev environment
sdev -m 8gb --pty --x11=first

If you need to obtain larger memory allocation on your node or a longer time-frame then use

salloc -N 1 -n 2 --mem-per-cpu=8G -t 4:00:00 --pty --x11=first

Once the node has been allocated, you can ssh into the first node and start an interactive matlab session using start_matlab

Notes: Mathworks also has patches for Java exception errors in older versions of MATLAB. There might be similar issues on linux systems. See here