If a cell is taking too long to run (for example, if it has code to train the model in deep learning) , how can I stop it from running in Google Colab.
Run the following cell and select Runtime -> Interrupt execution (hotkey: Cmd/Ctrl-M I) to stop execution.
You can also run only a part of the cell by selecting it and pressing the Runtime > Run Selection button or using the keyboard shortcut Ctrl + Shift + Enter .
Even though Colab notebooks can only run for a maximum of 12 hours, with the hacks shared above, you should be able to get the most out of your session.
Press the stop button, or select the 'Interrupt execution' item from the Runtime menu.
Keep in mind that some code cannot be interrupted. (For example, if you're using a C library stuck in a syscall.) In these cases, you can restart your Python process by selecting 'Restart runtime...' from the Runtime menu.
If you have a multi-cell file running and you need to stop a particular cell from running. Follow this:
Select the code from the google colab cell of interest.
Use ctrl + x to cut the code from the cell (or copy). Delete the cell (this stops the code from executing).
Now, create a new cell and paste the code you just copied.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With