The 'maximum lifetime' of a running notebook is 12 hours (browser open)
An 'Idle' notebook instance cuts-off after 90 minutes
You can have a maximum of 2 notebooks running concurrently
If you close the notebook window and open it while the instance is still running, the cell outputs and variables will still persist. However if the notebook instance has been recycled, your cell outputs and variables will no longer be available.
A sneaky workaround you can try is to have the Colabs instance open in your mobile browser in order to prevent the instance from being considered "Idle".
Your own milage will vary as from personal experience I sometimes get slighty shorter durations. But as long as you checkpoint your models (periodically save the training weights), you should be able to get a substantial amount of training done before the VM is recycled, after which you could simply load the weights into the model on a new VM instance and resume training.
If you'd like to train your model for more than 12 hours at a single go however, you can run Google Colaboratory on a local instance or a standard Jupyter Notebook. But you would forego the free GPU/TPU that Colaboratory provides. (Checkpointing would still be a good idea here!)
Where is my code executed? What happens to my execution state if I close the browser window?
Code is executed in a virtual machine dedicated to your account. Virtual machines are recycled when idle for a while, and have a maximum lifetime enforced by the system.
How may I use GPUs and why are they sometimes unavailable?
Colaboratory is intended for interactive use. Long-running background
computations, particularly on GPUs, may be stopped. Please do not use
Colaboratory for cryptocurrency mining. Doing so is unsupported and
may result in service unavailability. We encourage users who wish to
run continuous or long-running computations through Colaboratory’s UI
to use a local runtime.
for me, I choose ,chroot into VM by ssh Ngrok and run command shell (loop) in background while true;do sleep 300; done &
I'm using&` for to run this command in the background
so I can exit from website of colab and leave the VM working, for 12h
ssh Ngrok
The best way to use ssh in colab , you must sign one time in ngrok.com and get your OAuth key and add this cell to your colab notebook
now past your OAuth key in Edite text in colab cell , after 3-9 seconde you see your ssh like that
ssh root@2.tcp.ngrok.io -p 13225
dont forget change password of root user (default is root) ,for more security, you should be change linux password of root user !echo "root:new password" | chpasswd and from python variable by : password =password='new password' , you must matching linux password and var python password , look in this ligne above:
print("No user found using username and password as 'root'")
!echo "root:t" | chpasswd
username='root'
password='root'