Skip to content

Instantly share code, notes, and snippets.

@wflynny
Created June 6, 2019 15:28
Show Gist options
  • Save wflynny/c9153247dcffb522df7fa33a7c29acc5 to your computer and use it in GitHub Desktop.
Save wflynny/c9153247dcffb522df7fa33a7c29acc5 to your computer and use it in GitHub Desktop.
Running jupyter on a cluster
#!/usr/bin/env bash
#### PBS preamble
#PBS -N jupyter-server
#PBS -o /path/to/software/logs/jupyter-server.${PBS_JOBID%%.*}.out
#PBS -j oe
#PBS -m n
#PBS -l mem=128GB
#PBS -l vmem=128GB
#PBS -l nodes=1:ppn=1
#### PBS preamble
#### SLURM preamble
#SBATCH --job-name=jupyter-server
#SBATCH --output=/path/to/software/logs/jupyter-server.${SLURM_JOBID%%.*}.out
#SBATCH --mem=128000
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=1
#SBATCH --export=NONE #ALL
#### SLURM preamble
# change dirs to home directory
# TODO: if you want to access your /projects/ dir, change this to
# `cd /projects/$USER/`
# or symlink your projects to your
# home directory
cd
# load up your conda environment
# TODO: change this to suit your needs/load your own python/conda and change envs.
# I do it through using a user-defined modulefile:
module use -a /path/to/software/modules
module load conda
# get nodes IP address
# TODO: If you aren't me, change this port number please!!
IPADDR=$(hostname -i)
if [[ -z "${PORT}" ]]; then
PORT=8899
fi
# TODO: before launching, *please* make sure you have already run
# jupyter notebook --generate-config
# jupyter notebook password
# in order to password protect your notebook server. Otherwise, anyone who stumbles upon your server
# will have write permissions as if they are you
# launch notebooks
jupyter notebook \
--no-browser \
--ip=${IPADDR} \
--port=${PORT}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment