google-colaboratory

Google Colab - How to 'restart runtime' using python code or command line interface?


Can someone suggest me programatically 'restart runtime'? Any programmatically restarting option is fine, python or CLI (Command Line Interface), without using GUI.


Solution

  • Run a cell with the following code snippet:

    import os
    os.kill(os.getpid(), 9)
    

    That will kill the current Python runtime process, which will be automatically restarted by the manager.