PROBLEM:
I have to training my model for hours but the google colab keeps disconnecting after 30 mins automatically if I do not click frequently, leading to loss of all data.
SOLUTION:
Steps:
- Open the inspector view by typing
Ctrl+ Shift + i
and then clicking on console tab at top. - Paste the below code snippet at bottom of console and hit enter
function ClickConnect(){
console.log("Working");
document.querySelector("#top-toolbar > colab-connect-button").shadowRoot.querySelector("#connect").click();
}
setInterval(ClickConnect,60000)
- Believe me, that’s all folks.
Above code would keep on clicking the page and prevent it from disconnecting.
Below is the image showing console view of above steps:-
Alternatively you can also try below snippet:
interval = setInterval(function() {
console.log("working")
var selector = "#top-toolbar > colab-connect-button"
document.querySelector(selector).shadowRoot.querySelector("#connect").click()
setTimeout(function() {
document.querySelector(selector).shadowRoot.querySelector("#connect").click()
}, 1000)
}, 60*1000)