Introduction to the Cluster

Amanda Mejia
BST 753 Spring 2014

What is the cluster?

First, let's get on the cluster

  • Open the terminal or PuTTY
  • Type ssh yourusername@enigma2.jhsph.edu
    • Now you're on enigma!
  • Type qrsh to get on a node
    • Now you're on a node! Do everything from a node except submitting batch jobs, which can only be done from enigma
  • When you're done, type exit to go back to enigma
  • Type exit again to exit enigma

Basic Unix commands (1 of 2)

  • Change directory: cd
    • Subdirectory: cd [subdir]
    • Home directory: cd ~/
    • New directory: cd /new/path/
    • Go up a directory: cd ..
  • Print current working directory: pwd
  • List files: ls
  • Create new directory: mkdir [dirname]
  • Copy file: cp [filename]
  • Delete file: rm [filename]
  • Move or rename file:
    • Move: mv [filename] [newlocation]
    • Rename: mv [oldname] [newname]

Basic Unix commands (2 of 2)

  • View or edit text files:
    • This includes .txt, .sh, .R, etc.
    • cat [filename] to view entire file
    • head [filename] or tail [filename] to preview file
    • less [filename] or more [filename] to scroll through file (hit q to exit)
    • emacs -nw [filename] to view and edit file
  • Options with "-". Examples include:
    • ls -l lists files and includes file information
    • rm -f [filename] forces removal of file without prompting
    • matlab -nodisplay opens MATLAB on the command line (without the interactive display window)
  • Tab completion (for file or directory names)
  • Google is your friend!

Exercise

  1. Get onto enigma and qrsh to get onto a node
  2. List the files in your home directory (that's where you are)
  3. Create a new directory called "BST753" within your home directory
  4. Copy a file from your home directory into BST753
  5. Go into BST753 and look at the files
  6. Go back to your home directory

Working Interactively in R

  • First, make sure you are on a node!
  • Type R
  • Do stuff!
  • Reading and saving data
    • Read files from locations on the cluster
    • Save R data files (.Rdata, .rda) within your home directory
  • Plotting
    • If X11 is set up, plots will display
    • Otherwise, save plots using pdf() or png() functions
  • When finished, exit R by typing q()

Submitting batch jobs

  1. Get on enigma
  2. Go to the directory where your code is using cd path/to/code
  3. Create a "shell script" that will run your R code using emacs -nw shellscriptname.sh
  4. Write shell script (next slide)
  5. Exit emacs and save file by typing Ctrl-X Ctrl-C then y
  6. Submit job by typing qsub shellscriptname.sh

Shell script

#!/bin/sh
#$ -cwd 
#$ -l mf=40G,h_vmem=40G,h_fsize=10G 
#$ -m e -M youremail@jhsph.edu

R CMD BATCH --no-save --no-restore Rfilename.R

Additional Resources