How to stop an instance in gcp using jupyter notebook?

Hi! I wanted to leave a model training and go to bed. My training procedure has an early stopping callback so, whenever the training it is not helping anymore it will stop. I would like then to also stop the instance so that if it happens middle of the night it stops charging me. Usually, I execute the following command from my computer (ubuntu) in which I have installed google clould sdk. I tried to do the same from jupyter notebook but I get the following error.


How do you do it? I am sure I am not the first one to face this issue.

1 Like

You can stop an instance from within using sudo shutdown -h now or ! sudo shutdown -h now inside a Jupyter notebook.

https://cloud.google.com/compute/docs/instances/stop-start-instance

1 Like