Last active
April 17, 2024 01:30
-
-
Save korakot/4e555f1ff9fb79e5a426880a0b4f4270 to your computer and use it in GitHub Desktop.
Terminate kernel to restart google colab
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, signal | |
os.kill(os.getpid(), signal.SIGKILL) | |
# not sure if this also works the same way | |
!kill -9 -1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://twitter.com/GoogleColab/status/1569389018311426051?s=20&t=627yQ2meQzQDPyD8gWixdA | |
quit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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