Running Jupyter lab on RC cluster

All credit to Nils Wendt for the method.

Part 1

  1. Login to your RC cluster

    ssh <username>@login.rc.fas.harvard.edu
    
  2. Launch an interactive job from the cluster with around 8 GO of RAM and a specified time and leave this terminal a side

    srun --pty -p cox -t 0-12:00 --mem 8000 /bin/bash
    
  3. Forward a port from your local computer to the cluster, this port will be used for Jupyter Lab

    ssh -L <port number>:localhost:<port number> <username>@login.rc.fas.harvard.edu
    
  4. In the same termiinal, you should be now on the cluster. Forward a port from the cluster to the interactive job allocated partition. Partition name is obtained from the interactive job terminal, for example coxgpu01. The port number needs to be the same, for example 2626

    ssh -L <port number>:localhost:<port number> <partition>
    

You are all set and you only need to launch Jupyter Lab with the port number specified previously ! We will continue working from the last terminal which is now running on the partition specified earlier.

Part 2

  1. Make sure to load anaconda module on your RC

    module load Anaconda3/5.0.1-fasrc02
    
  2. Create/Activate your conda environment you like to use

    If not already created : conda create -n <environment>
    
    source activate <environment>
    
  3. Launch Jupyter Lab

    jupyter lab --no-browser --port=<port number>
    
  4. Finally copy the Jupyter Lab link you get on the terminal and paste on your local computer browser. You are all set now.

Useful aliases and bash functions

  1. Local computer

    fwport() { ssh -L ${1}:localhost:${1} <username>@login.rc.fas.harvard.edu; }
    
  2. RC cluster

    alias loadconda='module load Anaconda3/5.0.1-fasrc02'
    
    
    gpujob() { srun --pty -p cox -t 0-12:00 --mem ${1} /bin/bash; }
    
    
    fwport() { ssh -L ${1}:localhost:${1} ${2}; }
    
    
    fwjl() { jupyter lab --no-browser --port=$1; }