Skip to content

Latest commit

 

History

History
200 lines (137 loc) · 5.21 KB

jupyter_and_general_commands.md

File metadata and controls

200 lines (137 loc) · 5.21 KB

How to use the RWTH Aachen cluster

Getting an Aachen account

For this I reccomend following the Get access specified by Christof Seiler here.

Connecting to server

Create VPN connection with RWTH Aachen

For this, install Cisco AnyConnect.

Connect to vpn.rwth-aachen.de using a Split Tunnel connection. With your user and pw.

Ssh the server

For this use the following command on the terminal.

Useful commands

Checking hardware/server load

For checking RAM in Gigabytes:

free -g 

For checking processor:

lscpu

To check for used corehours (out of the 2000 monthly allowed):

r_wlm_usage

To check current server load:

squeue -w linuxihdc160,linuxihdc161

Submission and handling of jobs

To submit job job.sh:

sbatch job.sh

To check for the state of your current batches:

squeue -u$(whoami)

To cancel job 12345:

scancel 12345

Running a remote jupyter notebook

You should copy the following template and paste it into a jobscript.sh file.

#!/usr/local_rwth/bin/zsh

#SBATCH --nodes=1
#SBATCH --ntasks-per-node=1
#SBATCH --mem-per-cpu=8G
#SBATCH --account="um_dke"
#SBATCH --gres=gpu:1
#SBATCH --time=1-0:00:00
#SBATCH --job-name=jupyter-notebook
#SBATCH --output=jupyter-notebook-%J.log


echo "------------------------------------------------------------"
echo "SLURM JOB ID: $SLURM_JOBID"
echo "Running on nodes: $SLURM_NODELIST"
echo "------------------------------------------------------------"
module switch intel gcc
module load python/3.6.0

#Install jupyter as local user
#Add the local python pip path to the front of the PATH variable
export PATH=$HOME/.local/bin:$PATH

# only run the following two lines the first time you're using a jupyter notebook
# pip3.6 install --user --upgrade pip 
# pip3.6 install --user jupyter

# set a random port for the notebook, in case multiple notebooks are
# on the same compute node.
NOTEBOOKPORT=`shuf -i 8000-8500 -n 1`

# set a random port for tunneling, in case multiple connections are happening
# on the same login node.
TUNNELPORT=`shuf -i 8501-9000 -n 1`

# set a random access token
TOKEN=`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 49 | head -n 1`

echo "On your local machine, run:"
echo ""
echo "ssh -L8888:localhost:$TUNNELPORT $SLURM_SUBMIT_HOST -N -4"
echo ""
echo "and point your browser to http://localhost:8888/?token=$TOKEN"
echo "Change '8888' to some other value if this port is already in use on your PC,"
echo "for example, you have more than one remote notebook running."
echo "To stop this notebook, run 'scancel $SLURM_JOB_ID'"

# set a random port for the notebook, in case multiple notebooks are
# on the same compute node.
NOTEBOOKPORT=`shuf -i 8000-8500 -n 1`

# set a random port for tunneling, in case multiple connections are happening
# on the same login node.
TUNNELPORT=`shuf -i 8501-9000 -n 1`

# set a random access token
TOKEN=`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 49 | head -n 1`

echo "On your local machine, run:"
echo ""
echo "ssh -L8888:localhost:$TUNNELPORT $(whoami)@$SLURM_SUBMIT_HOST -N -4"
echo ""
echo "and point your browser to http://localhost:8888/?token=$TOKEN"
echo "Change '8888' to some other value if this port is already in use on your PC,"
echo "for example, you have more than one remote notebook running."
echo "To stop this notebook, run 'scancel $SLURM_JOB_ID'"

# Set up a reverse SSH tunnel from the compute node back to the submitting host (login01 or login02)
# This is the machine we will connect to with SSH forward tunneling from our client.
ssh -R$TUNNELPORT\:localhost:$NOTEBOOKPORT $SLURM_SUBMIT_HOST -N -f

# Start the notebook
srun -n1 jupyter-notebook --no-browser --port=$NOTEBOOKPORT --NotebookApp.token=$TOKEN --log-level WARN
# To stop the notebook, use 'scancel'

Important to note are the lines:

# pip3.6 install --user --upgrade pip 
# pip3.6 install --user jupyter

That should be commented out on the first time running a remote jupyter notebook.

To create the jobscript file do:

nano jobscript.sh

Paste the shell file above and press control +X and then Y to save the file.

To start the notebook run:

sbatch jobscript.sh

Which will generate a log file of the form jupyter-notebook-12345.log open this file which will include instructions on how to open the notebook on your laptop.

Copy the line that specifies where 1111 will be a different port and user will be your Aachen user:

ssh -L8888:localhost:1111 [email protected] -N -4

Then in your preferred browser simply go to localhost:8888/

To close the notebook run the following command by first substituting 12345 for the job number that was given to you after running sbatch:

scancel 12345

Directory sync

Inspired by this.

For this we will use rsync:

rsync -aP ~directory/ [email protected]:directory