Thursday, October 6, 2022

[SOLVED] How to terminate current colab session from notebook cell

Issue

I'm trying to be a good citizen and make sure my notebook session is terminated immediately after running even if I'm not sitting at my machine.

Is there any code I can run in a notebook cell to achieve this?


Solution

We have a way to do this correctly now:

from google.colab import runtime
runtime.unassign()


Answered By - Aplefull
Answer Checked By - Timothy Miller (WPSolving Admin)