Alexandre Gentil
Alexandre Gentil

Reputation: 149

Google Cloud Platform jupyter notebook still running after switching off local PC

I'm new at GCP and I'm trying to keep my process running on Jupyter Notebook after shutting down my local PC. Does anyone know how can I do it? Nowaday I open a terminal on my VM run jupyter notebook and then after start the process on jupyter I'd like to turn my machine off.

I keep following the process on my cellphone and shutdown on there. Does anyone know how to turn this off automatically when it stops?

Sorry to make two questions at once, but I think that one is related with another. If it does not I can edit and make another one.

Upvotes: 3

Views: 4312

Answers (2)

Zain Rizvi
Zain Rizvi

Reputation: 24636

This is a technical limitation of Jupyter Notebooks unfortunately. The browser window contains the code which updates the notebook itself, so if you close the browser window then there is not process running to update the notebook.

However, there is one workaround which you may find useful.

There is a library called Fairing that you can use with GCP's new AI Platform Notebooks which allows you to pack up your notebook and run it remotely, and that library will save the results of that execution in a GCP Storage bucket. No active internet connection required (once you kick of the notebook run).

You can learn how to use it by creating a new GCP AI Platform Notebook and looking at the tutorials folder inside it. You can also find additional tutorials for Fairing here

Upvotes: 4

Dan Cornilescu
Dan Cornilescu

Reputation: 39814

Typically to keep your remote sessions up in the event of network connectivity loss (which also covers shutting down the local computer) you'd use a terminal multiplexer application. From Known issues:

Intermittent disconnects: At this time, we do not offer a specific SLA for connection lifetimes. Use terminal multiplexers like tmux or screen if you plan to keep the terminal window open for an extended period of time.

But these multiplexers are terminal/text-mode apps, so you'd have to launch the notebook with the --no-browser and then connect your local browser to its port.

You can find a recipe based on tmux and a local browser connection to the notebook using an SSH tunnel at Using Jupyter notebooks securely on remote linux machines.

As for shutting down the session - you'd just have to instruct the multiplexer application to end the session (or terminate the multiplexer app itself) - which you could do automatically via a wrapper script first invoking your process and immediately after the process ends invoking the commands to shutdown the session.

Upvotes: 1

Related Questions