Can I run a google colab (free edition) script and then shut down my computer?
I am training several deeplearning models with crossvalidation, and therefore I would like to know if I can close the window or the computer with the training running at the same time in the cloud.
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.
Google Colab notebooks have an idle timeout of 90 minutes and absolute timeout of 12 hours. This means, if user does not interact with his Google Colab notebook for more than 90 minutes, its instance is automatically terminated. Also, maximum lifetime of a Colab instance is 12 hours.
In the free version, runtimes are limited to 12 hours and RAM is also limited to 16 GB. In the pro variant, it is possible to select a high-memory option and thus use 32 GB of RAM. The Google Pro+ variant now offers even more options to run Deep Learning relatively inexpensively without a cloud server or local machine.
So to prevent this just run the following code in the console and it will prevent you from disconnecting. Ctrl+ Shift + i to open inspector view . Then goto console. It would keep on clicking the page and prevent it from disconnecting.
Edited: With the browser closed, a Colabs instance will run for at most
12 hours90 minutes before your runtime is considered idle and is recycled.
At the same time, it would be good practice to save your model weights periodically to avoid losing work.
Details:
There are no official references for 'Idle' and 'Maximum Lifetime' durations, but testing done by Korakot Chaovavanich shows that:
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!)
Relevant questions from the Google Colaboratory FAQ:
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.
Open your browser console and copy and paste the code bellow, that will avoid you to get kicked off for being idle.
function ClickConnect() {
console.log("Working");
document
.querySelector('#top-toolbar > colab-connect-button')
.shadowRoot.querySelector('#connect')
.click()
}
setInterval(ClickConnect, 60000)
Ps. You will get kicked after 12 hours no matter what, so be sure that you are saving your progress to your Google Drive.
for me, I choose ,chroot into VM by ssh Ngrok and run command shell (loop) in backgroundwhile 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
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
#@title **SSH**
! pip install colab_ssh --upgrade &> /dev/null
Ngrok = True
try:
if username:
pass
elif password:
pass
except NameError:
!echo "root:root" | chpasswd
username='root'
password='root'
#@markdown [OAuth](https://dashboard.ngrok.com/auth)
ngrokToken = "" #@param {type:'string'}
def runNGROK():
from colab_ssh import launch_ssh
from IPython.display import clear_output
launch_ssh(ngrokToken, password)
clear_output()
print("ssh", username, end='@')
! curl -s http://localhost:4040/api/tunnels | python3 -c \
"import sys, json; print(json.load(sys.stdin)['tunnels'][0]['public_url'][6:].replace(':', ' -p '))"
if Ngrok:
if ngrokToken == "":
print("No ngrokToken Found, Please enter it")
else:
runNGROK()
now past your OAuth key in Edite text in colab cell , after 3-9 seconde you see your ssh like that
ssh [email protected] -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'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With