Skip to content

Instantly share code, notes, and snippets.

@korakot
Last active April 17, 2024 01:30
Show Gist options
  • Save korakot/4e555f1ff9fb79e5a426880a0b4f4270 to your computer and use it in GitHub Desktop.
Save korakot/4e555f1ff9fb79e5a426880a0b4f4270 to your computer and use it in GitHub Desktop.
Terminate kernel to restart google colab
print("Runtime is now restarting...")
print("You can ignore the error message [Your session crashed for an unknown reason.]")
sleep(0.5)
os._exit(0) # restart
import os, signal
os.kill(os.getpid(), signal.SIGKILL)
# not sure if this also works the same way
!kill -9 -1
# https://twitter.com/GoogleColab/status/1569389018311426051?s=20&t=627yQ2meQzQDPyD8gWixdA
quit()
# from condacolab
print("🔁 Restarting kernel...")
get_ipython().kernel.do_shutdown(True)
# or
app = IPython.Application.instance()
app.kernel.do_shutdown(True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment