Google Colab hangs evaluating trivial cells

Viewed 999

Quite frequently Google Colab gets hung up on extremely simple cells (stuff like setting variables or defining a function--not evaluating!).

For a very explicit example, I just started a new runtime and evaluated cell 1 (below). Then colab got hung on evaluating cell 2:

Cell 1 (ran):

import numpy as np
import scipy.sparse as sparse
import matplotlib.pyplot as plt

Cell 2 (stopped colab):

delta_t = .01

This appears to have nothing to do with how many cells have been evaluated -- sometimes it gets hung up on the first cell.

This is obviously quite annoying as the only solution is to restart the entire runtime.

However I have noticed that I can sometimes copy the code to a new cell, and then evaluate it there. I.e. while the first cell is still trying to evaluate, I can run the same code in a different cell and have it successfully complete.

Is there anything I can do to avoid this?

1 Answers

Your example works just fine, and it's not supposed to produce any error. Of course, Google Colab has its limitations, but setting variables and defining a function are not one of them.

Put in mind that Colab Notebooks run by connecting to virtual machines that have maximum lifetimes that can be as much as 12 hours. Notebooks will also disconnect from VMs when left idle for too long. Maximum VM lifetime and idle timeout behavior may vary over time, or based on your usage.

In case of having internet connection problems in your client machine, you may get hung up too.

You can check more about Google Colab limitations here https://research.google.com/colaboratory/faq.html#resource-limits

Related