diff --git a/src/jupyterlabs/run.sh b/src/jupyterlabs/run.sh deleted file mode 100755 index 9e8d21f..0000000 --- a/src/jupyterlabs/run.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/encs/bin/tcsh - -cd /speed-scratch/$USER/Jupyter -module load anaconda3/2023.03/default -setenv TMPDIR /speed-scratch/$USER/tmp -setenv TMP /speed-scratch/$USER/tmp -setenv CONDA_PKGS_DIRS /speed-scratch/$USER/Jupyter/pkgs -conda activate /speed-scratch/$USER/Jupyter/jupyter-env -jupyter lab --no-browser --notebook-dir=$PWD --ip="0.0.0.0" --port=8888 --port-retries=50 - diff --git a/src/jupyterlabs/run_jupyterlab.sh b/src/jupyterlabs/run_jupyterlab.sh new file mode 100755 index 0000000..5da593e --- /dev/null +++ b/src/jupyterlabs/run_jupyterlab.sh @@ -0,0 +1,43 @@ +#!/encs/bin/tcsh + +# Navigate to the Jupyter directory +cd /speed-scratch/$USER/Jupyter || exit + +# Load Anaconda module if not already loaded +if (! $?CONDA_PREFIX) then + module load anaconda3/2023.03/default +endif + +# Set temporary directories for faster I/O +setenv TMPDIR /speed-scratch/$USER/tmp +setenv TMP /speed-scratch/$USER/tmp +setenv CONDA_PKGS_DIRS /speed-scratch/$USER/Jupyter/pkgs + +# Activate the Conda environment +conda activate /speed-scratch/$USER/Jupyter/jupyter-env +if ($status != 0) then + echo "Failed to activate the conda environment" + exit 1 +endif + +# Get the current node and user information +set node = `hostname -s` +set user = `whoami` + +# Get an available port for Jupyter +set port = `python -c 'import socket; s=socket.socket(); s.bind(("", 0)); print(s.getsockname()[1]); s.close()'` + + +# Print SSH tunneling instructions +echo "To connect to the compute node ${node} on speed.encs.concordia.ca running your Jupyter notebook server, \n\ +use the following SSH command in a new terminal on your workstation/laptop:\n\n\ +ssh -L ${port}:${node}:${port} ${user}@speed.encs.concordia.ca\n\n\ +Then, copy the URL provided below by the Jupyter server (starting with http://127.0.0.1/...) and paste it into your browser.\n\n\ +Remember to close any open notebooks and shut down the Jupyter client in your browser before exiting to avoid manual job cancellation." + + +# Start the Jupyter server in the background +echo "Starting Jupyter server in background with requested resources" +jupyter lab --no-browser --notebook-dir=$PWD --ip="0.0.0.0" --port=${port} --port-retries=50 + + diff --git a/src/jupyterlabs/firsttime.sh b/src/jupyterlabs/setup_conda.sh similarity index 100% rename from src/jupyterlabs/firsttime.sh rename to src/jupyterlabs/setup_conda.sh diff --git a/src/jupyterlabs/start_jupyterlab.sh b/src/jupyterlabs/start_jupyterlab.sh new file mode 100755 index 0000000..57446b7 --- /dev/null +++ b/src/jupyterlabs/start_jupyterlab.sh @@ -0,0 +1,2 @@ +srun --mem=16G --gpus=1 /speed-scratch/$USER/speed-hpc/src/jupyterlabs/run_jupyterlab.sh +