Note: These instructions cover jupyter-notebook 6.4.5, though should be easily adaptable for both newer versions and jupyter-lab.
Before beginnning this work, please select a random number between 4096 and 16384 for your Jupyter-Notebook server to start on. It is important that this number is unique and does not conflict with either another user or an existing service on your machine. From this point out, we will use 9195 as an example.
- Install Jupyter Notebook
- Miniconda (using a conda environmentconda create -n jupyter-notebookconda activate jupyter-notebookconda install -c conda-forge notebook
- Pip (using a virtualenv)python3 -m venv ~/venvs/jupyter-notebooksource ~/venvs/jupyter-notebook/bin/activatepip3 install notebook
- Miniconda (using a conda environment
- Open a job allocation with the desired specs for use by Jupyter.ryanmcgr@klone1: salloc -A uwit -p compute --time=4:00:00 --mem=10G -c 4salloc: Pending job allocation 1546486salloc: job 1546486 queued and waiting for resourcessalloc: job 1546486 has been allocated resourcessalloc: Granted job allocation 1546486salloc: Waiting for resource configurationsalloc: Nodes n3097 are ready for jobryanmcgr@n3097:
- Activate the environment containing jupyter-notebook using the method stated above.ryanmcgr@n3097: source ~/venvs/jupyter-notebook/bin/activate(jupyter-notebook) ryanmcgr@n3097:
- (Optional) Configure a setting file for Jupyter-Notebook, to more permanently set options such as ip, port, and password.~/.jupyter/jupyter_notebook_config.py(jupyter-notebook) ryanmcgr@n3097: jupyter-notebook --generate-config(jupyter-notebook) ryanmcgr@n3097: jupyter-notebook passwordEnter password:Verify password:[NotebookPasswordApp] Wrote hashed password to ~/.jupyter/jupyter_notebook_config.json(jupyter-notebook) ryanmcgr@n3097: vim ~/.jupyter/jupyter_notebook_config.py####CHANGED SETTINGS###### The port the notebook server will listen on (env: JUPYTER_PORT).c.NotebookApp.port = 9195## The IP address the notebook server will listen on.c.NotebookApp.ip = '0.0.0.0'
- Start the Jupyter-Notebook server. Note that if a configuration was created above, the port and ip are not required as part of the command line.(jupyter-notebook) ryanmcgr@n3097: jupyter-notebook --port 9195 --ip 0.0.0.0[I 18:00:06.106 NotebookApp] Serving notebooks from local directory: /mmfs1/home/ryanmcgr[I 18:00:06.106 NotebookApp] Jupyter Notebook 6.4.5 is running at:[I 18:00:06.106 NotebookApp] http://n3097.hyak.local:9195/[I 18:00:06.106 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).[W 18:00:06.135 NotebookApp] No web browser found: could not locate runnable browser.
- Using the address provided in the response, open another SSH session, this time including the address and port as a local single-port forward. More can be found here: Configuring SSH Single-Port Forwarding
- If properly configured, the server should be accessible by opening your browser and navigating to http://localhost:9195.