Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I stop a particular cell from running in google colab?

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.

like image 902
bhatnaushad Avatar asked Jan 09 '19 07:01

bhatnaushad


People also ask

How do you stop run a cell in Google Colab?

Run the following cell and select Runtime -> Interrupt execution (hotkey: Cmd/Ctrl-M I) to stop execution.

How do I run selected cells in Google Colab?

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 .

How long can a cell run in Google Colab?

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.


2 Answers

Press the stop button, or select the 'Interrupt execution' item from the Runtime menu.

enter image description here

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.

like image 68
Bob Smith Avatar answered Oct 07 '22 08:10

Bob Smith


If you have a multi-cell file running and you need to stop a particular cell from running. Follow this:

A multicell notebook is running

Select the code from the google colab cell of interest.

Select the code

Use ctrl + x to cut the code from the cell (or copy). Delete the cell (this stops the code from executing).

Delete the cell

Now, create a new cell and paste the code you just copied.

like image 35
Iceman_R1331 Avatar answered Oct 07 '22 07:10

Iceman_R1331