Google Colab variable values lost after VM recycling

Viewed 3288

I am using a Google Colab Jupyter notebook for algorithm training and have been struggling with an annoying problem. Since Colab is running in a VM environment, all my variables become undefined if my session is idle for a few hours. I come back from lunch and the training dataframe that takes a while to load becomes undefined and I have to read_csv again to load my dataframes.

Does anyone know how to rectify this?

2 Answers

If the notebook is idle for some time, it might get recycled: "Virtual machines are recycled when idle for a while" (see colaboratory faq) There is also an imposed hard limit for a virtual machine to run (up to about 12 hours !?).

What could also happen is that your notebook gets disconnected from the internet / google colab. This could be an issue with your network. Read more about this here or here

There are no ways to "rectify" this, but if you have processed some data you could add a step to save it to google drive before entering the idle state.

Related