generated from IMMM-SFA/metarepo
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathslurm_jupyter.sh
30 lines (22 loc) · 979 Bytes
/
slurm_jupyter.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=1
#SBATCH --time=08:00:00
#SBATCH --job-name=jupyter_launch
#SBATCH --output=jupyter-%j.log
#SBATCH --error=jupyter-%j.err
source /home/fs02/pmr82_0001/ah986/rival_framings/bin/activate
# set a random port for the notebook, in case multiple notebooks are
# on the same compute node.
NOTEBOOKPORT=`shuf -i 18000-18500 -n 1`
# set a random port for tunneling, in case multiple connections are happening
# on the same login node.
TUNNELPORT=`shuf -i 18501-19000 -n 1`
# 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
echo "FWDSSH='ssh -L8888:localhost:$TUNNELPORT $(whoami)@$SLURM_SUBMIT_HOST -N'"
# Start the notebook
srun -n1 jupyter notebook --no-browser --no-mathjax --port=$NOTEBOOKPORT
wait