Is there a function in google.colab module to close the runtime

Question:

Sometimes when I give run in google.colab I cant stay infront of the computer to manually disconnect from the server when the run is complete and the connection stays on even when my run is complete occupying the node for no reason.

Is there a function in google.colab so that say I can insert the function to close the connection after some epochs? I am looking for something like colab.disconnect() etc…

Asked By: Sina

||

Answers:

import sys
sys.exit()

This will end the runtime, freeing up the GPU.

EDIT: Apparently my last answer doesn’t work any more.
The thing to do now is !kill -9 -1.

Answered By: Omegastick

quit() and exit() are not executed in google colab (18 Aug 2019). Just type the following:

!kill -9 -1
Answered By: Farzad Amirjavid

We have a way to do this correctly now:

from google.colab import runtime
runtime.unassign()
Answered By: Aplefull