Stealing pages from the server...

Prevent Colab from Disconnecting


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.

Solution

It is wonderful that Google colab can use GPU, TPU, and other computing resources for artificial intelligence calculation for free, but the calculation page will be automatically dropped after a period of no operation, and the previous training data will be lost, which is disappointing.

Finally found a way to keep it from going offline automatically, with a JavaScript program that automatically clicks the connect button.

Step 1: Press the shortcut keys CTRL + SHIFT + I and select Console.

Step 2: Copy and paste the below code, and hit ENTER, the program will be ready to run.

function ClickConnect(){
  console.log("Working"); 
  document
    .querySelector("#top-toolbar > colab-connect-button")
    .shadowRoot
    .querySelector("#connect")
    .click()
}
 
setInterval(ClickConnect, 5*60000)

If you still have problems running it or want to get more methods, you can refer here.


Author: Yang Wang
Reprint policy: All articles in this blog are used except for special statements CC BY 4.0 reprint polocy. If reproduced, please indicate source Yang Wang !
 Previous
Twitter Hate Speech Detection Twitter Hate Speech Detection
The objective of this task is to detect hate speech in tweets. For the sake of simplicity, let's say a tweet contains hate speech if it has a racist or sexist sentiment associated with it. So, the task is to classify racist or sexist tweets from other tweets.
2021-02-07
Next 
SSH into Google Colab SSH into Google Colab
Sometimes the code I write may not work in my local machine, however, it works in Google Colab. So, I wanna connect to Google Colab terminal using SSH.
2021-02-06
  TOC