I was running a ML model in a python GCP VM, and results(visualizations) are stored in a jupyter notebook. So I installed jupyter notebook to the ubuntu vm and ran jupyter from the relevant location using jupyter notebook --ip=0.0.0.0 --port=8888 --no-browser
command. It gave this output
_ _ _ _
| | | |_ __ __| |__ _| |_ ___
| |_| | '_ \/ _` / _` | _/ -_)
\___/| .__/\__,_\__,_|\__\___|
|_|
Read the migration plan to Notebook 7 to learn about the new features and the actions to take if you are using extensions.
https://jupyter-notebook.readthedocs.io/en/latest/migrate_to_notebook7.html
Please note that updating to Notebook 7 might break some of your extensions.
[I 14:16:46.732 NotebookApp] Registered dataproc_jupyter_plugin server extension
jupyter_http_over_ws extension initialized. Listening on /http_over_websocket
[W 14:16:47.328 NotebookApp] Loading JupyterLab as a classic notebook (v6) extension.
[C 14:16:47.328 NotebookApp] You must use Jupyter Server v1 to load JupyterLab as notebook extension. You have v2.12.5 installed.
You can fix this by executing:
pip install -U "jupyter-server<2.0.0"
[I 14:16:47.406 NotebookApp] [Jupytext Server Extension] Deriving a JupytextContentsManager from LargeFileManager
[I 14:16:47.628 NotebookApp] [nb_conda] enabled
[C 14:16:47.676 NotebookApp] You must use Jupyter Server v1 to load nbdime as a classic notebook server extension. You have v2.12.5 installed.
You can fix this by executing:
pip install -U "jupyter-server<2.0.0"
[I 14:16:47.678 NotebookApp] Serving notebooks from local directory: current_terminal_location
[I 14:16:47.678 NotebookApp] Jupyter Notebook 6.5.6 is running at:
[I 14:16:47.678 NotebookApp] http://base_url:8888/?token=token_value
[I 14:16:47.678 NotebookApp] or http://#.#.#.#:8888/?token=token_value
[I 14:16:47.678 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 14:16:47.681 NotebookApp]
To access the notebook, open this file in a browser:
file:///path_to_jupyter_runtime/nbserver-684890-open.html
Or copy and paste one of these URLs:
http://base_url:8888/?token=token_value
or http://#.#.#.#:8888/?token=token_value
anyway when I tried to access the given links:
http://base_url:8888/?token=token_value
or http://#.#.#.#:8888/?token=token_value
the jupytor notebook isn't loading and browser is saying can't reach the page
I did two things
jupyter notebook --generate-config
Ensured to generate the jupyter_notebook_config.py
file at location: /.jupyter/jupyter_notebook_config.py
usingsudo vi /home/user_name/.jupyter/jupyter_notebook_config.py
added following lines in the vi editor
c.NotebookApp.ip = '*'
c.NotebookApp.open_browser = False
c.NotebookApp.port = 8888
exited from the vi editor by esc + :wq command
then ran the same command
jupyter notebook --ip=0.0.0.0 --port=8888 --no-browser
nothing new, same result what did I miss
After running jupyter notebook, it gives a url which opens with localhost, ie:
Jupyter Server 2.14.1 is running at:
http://group-10-rl-project-vm:8888/tree?token=7a9bf91f443bf2a02cbdb3a7de68d2f69dd8f36da6cd8ffe
http://127.0.0.1:8888/tree?token=7a9bf91f443bf2a02cbdb3a7de68d2f69dd8f36da6cd8ffe
I wasn't aware 127.0.0.1:8888
was similar to localhost
. So jupiter notebook is generating a URL which only opened inside the local machine. So we have to map it to another port which expose the Jupiter notebook to internet. I had already mapped port 8888
to output exposing port using the firewall policy (have mentioned in the question). So, I just needed to change the IP address of above URL to the External IP address. I went to check the External IP address of my VM
as in the image instead of http://127.0.0.1:8888
I replaced the IP as http://34.170.61.186:8888
and it worked. Token is regenerated when a new session is started and we can put the new URL.
Here's another method. I tried with the answer given in this: ssh pipeline method. And was able to access the vm from my local machine. finally I opened the jupyter notebook from http://localhost:8005
and gave the token.