Reputation: 402
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.
Upvotes: 22
Views: 43471
Reputation: 15
write a code cell 1/0
and this will return an error like this:
This is the trick to stop the code from running past this point.
Now you can RUN ALL of notebook.. or from a particular point.. and code will stop at this error.
---------------------------------------------------------------------------
ZeroDivisionError Traceback (most recent call last)
<ipython-input-63-9e1622b385b6> in <module>()
----> 1 1/0
ZeroDivisionError: division by zero
Upvotes: -1
Reputation: 97
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.
Upvotes: 7
Reputation: 38579
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.
Upvotes: 16