skip to Main Content

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

  1. I added a firewall policy in VPC Network > Firewall Rules by:
  • Clicked "Create Firewall Rule".
  • Set the following:
  • Name: Allow-Jupyter
  • Targets: All instances in the network
  • Source IP ranges: 0.0.0.0/0
  • Allowed protocols and ports: tcp:8888
  • Click "Create".
  1. In VM I followed what mentioned in here
    Add the firewall rule for the port where I wanted to run the jupyter (eg. 8888)
    jupyter notebook --generate-config
    Ensured to generate the jupyter_notebook_config.py file at location: /.jupyter/jupyter_notebook_config.py using

sudo 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

2

Answers


  1. Chosen as BEST ANSWER

    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.
    Although I was able to open the notebook from my local machine, that wasn't my purpose, I wanted to expose a port from my vm, and access the given jupyter url from my local machine.


  2. According to logs suggest that you need to downgrade your Jupyter Server to version 1.x. You can do this by running pip install -U "jupyter-server<2.0.0" as suggested in the logs

    Replace the base_url and token_value in the URL with the actual values when you try to access the Jupyter notebook. The base_url should be the external IP of your VM, and token_value is the token generated when you start the Jupyter notebook.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search