Automated launch of a jupyter notebook from GCP

Hello fastai fellows !

I am running the fastai library on a google cloud instance, and I wanted to automate my jupyter server to run when I start my GPU instance, using startup scripts ( never loose time while an instance is running :money_mouth_face: ).

Well, I first opened port 8080 for tcp connection within the google cloud platform.

I created a fixed IP adress for my instance

Then I edited jupyter configurations as follow, in the file ~/.jupyter/jupyter_notebook_config.py:

c = get_config()
c.NotebookApp.notebook_dir = '/home/marceau/ml'
c.NotebookApp.ip = '*'
c.NotebookApp.open_browser = False
c.NotebookApp.port = 8080

Then I edited startup script in the GCP console:

#!/bin/bash
cd /home/marceau
touch test.txt
jupyter notebook --allow-root --port=8080

This script is fired, but I cannot access my server at http://externalIP:8080

I opened the log file of the startup script which is in /var/log/daemon.log in debian, and it seems that the server is online:

[I 09:16:25.496 NotebookApp] Serving notebooks from local directory: /home/marceau
[I 09:16:25.497 NotebookApp] The Jupyter Notebook is running at:Jun 28 09:16:25 
[I 09:16:25.497 NotebookApp] http://localhost:8080/?token=****************
[I 09:16:25.497 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[W 09:16:25.505 NotebookApp] No web browser found: could not locate runnable browser.
[C 09:16:25.506 NotebookApp]
To access the notebook, open this file in a browser:
 file:///root/.local/share/jupyter/runtime/nbserver-1137-open.html
Or copy and paste one of these URLs:
http://localhost:8080/?token=*********************

I do not understand why I cannot reach this server…
Hoping that an advanced GCPxJupyter users has a clue :sweat_smile:

Thank you :vulcan_salute:

1 Like

Use this cmd in local system after install gcp sdk.

gcloud beta compute --project "project-id" ssh --zone "zone-name" "jupyter@tensorflow-1-vm" -- -L 8080:localhost:8080

After this you can access notebook in local browser at port 8080.
This method is safer.

1 Like