Google colab stops working and got disconnected - google-colaboratory

while training my model google colab stops working and kernel got disconnected. What can I do to restart and continue my training ?

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.
The one of the easiest method to prevent it from disconnecting is you can insert one more cell to the below and type
while True:pass
There are another methods to do that as well, one of these is:
You can basically open the console prompt and type
function ConnectButton(){
console.log("Connect pushed");
document.querySelector("#top-toolbar > colab-connect-button").shadowRoot.querySelector("#connect").click()
}
setInterval(ConnectButton,60000);
this is a js code which clicks on the connect button every 60 seconds to keep your session alive.
For long training files I recommend you to use GPU and local runtimes.

Related

How can maximum runtime in Colab be extended?

I use ColabPro for my deep learning work. Currently the ETA for every epoch is ~26 hours. I use the following code to avoid disconnection in the console:
function ClickConnect(){
console.log("Clicked on connect button");
document.querySelector("colab-connect-button").click()
}setInterval(ClickConnect,60000)
This code does maintain the interaction with Colab window.
However, I would like to know if this will help to automatically reconnect and get the code running beyond 24 hrs i.e. maximum runtime of ColabPro?

Prevent a Google Colab Process from being disconnected

Suppose I have to move out 3 hours away from my girlfriend's apartment, and I am running a Colab Environment. I can't stop the process and I need to bring my computer with me. How can I prevent the running process from being disconnected?
I have tried that question, but I think the Google Colab Interface has changed a bit, so the answers are no longer up-to-date.
There are many answers there. Currently for me works perfectly to go to the console and type
function ClickConnect(){
console.log("Clicked on connect button");
document.querySelector("colab-connect-button").click()
}
setInterval(ClickConnect,60000)
Take note that this should prevent disconnecting after each 1.5 hours of inactivity, but each runtime, if you don't have Colab Pro, will be terminated after 12 hours.
Edit:
I have tested my self and come up that this works:
function ClickConnect(){
console.log("Clicked on connect button");
document.querySelector("#ok").click()
}
setInterval(ClickConnect,60000)
Note that it will throw an error, its ok, it means that the Disconnection notification is not shown. Once it appear it will be clicked to reconnect.
There is this article from towards science that might help you prevent colab from disconecting
As a second thought, I think that as long as your laptop stays connected and active to a network it will keep running, so, an alternative is to use your phone as a hotspot to connect; use ethernet && wifi all together in order when you remove the cable you'll still be connected. But you have to keep your laptop open so you need battery fully charged; otherwise use a different device to start colab from like phone or tablet.

Dealing with timeouts in Sauce Labs

I have Web Driver code that works without issue when running on a local instance of a browser. My code interacts with the browser, but has a period where it kicks off some background tasks via terminal in order to set up data for the remainder of the test. This is an end to end test and it needs to execute in this order, leaving the browser idle for a short period of time, usually under 5 minutes. After the background tasks complete, the browser is then again interacted with.
Unfortunately when I run my rests remotely from Sauce Labs, when running the background tasks Sauce Labs finds the browser as being inactive for longer than 90 seconds and assumes there is an issue. This results in a failure even though the test never fails. I can't seem to find anything in the documentation regarding how to increase the idle timeout. Is there a way to do this?
Saucelabs has a few different types of timeouts:
Max test duration
Command timeout
Idle test timeout
More info: https://wiki.saucelabs.com/display/DOCS/Test+Configuration+Options#TestConfigurationOptions-Timeouts
Either the max duration or idle timeout should help you out. I think the idle time still burns down sauce test minutes though.
when you set up your desired_capabilities add:
desired_capabilities["idle-timeout"] = "180"
I did 180 seconds here, but you can do whatever...

Network operation fails after switching the network

I am using Core WLAN framework to switch between WiFi networks. I am facing a problem that after I switch from WiFi network 1 to WiFi 2, I have to wait for 10 seconds before I instantiate any network activity. Though the WiFi symbol shows the correct value before I put a wait for 10 seconds. Anyone has any clue as why this happens? And any remedy for this.
Core WLAN Framework link:
http://developer.apple.com/library/mac/#documentation/Networking/Reference/CoreWLANFrameworkRef/_index.html
There is no way to predict how long it will take to have a given network assign your system an IP address, for DNS resolution to begin to work, etc etc. Instead of waiting for a specific timeout, use the SCNetworkReachability API to take action when the system can access a given host or service.
Sample code: http://developer.apple.com/library/ios/#samplecode/Reachability/Introduction/Intro.html

Long polling Windows Phone, 60 seconds TimeOut

HelloA Windows Phone application need to connect to a server and get messages from it. This is done using WCF and long polling on the server. 3 minutes is the timeout defined on the server. Call from windows phone is done using HttpWebRequest.
The problem is that Windows Phone devices have a timeout of 60 seconds for get request (emulator have a different value, greater than 3 minutes).
Currently i can't decrease server timeout. Doing a new GetRequest after the 60 seconds doesn't get anymore messages.
Does anyone have an idea ?
Thanks
I don't think leaving a connection open is a good idea on mobile devices. I'm assuming that's what you're doing. In my app, I would just poll whenever needed by creating a new HttpWebRequest. But it made sense to do this in my app, because I would be updating train arrival status every 40 seconds.
If you're trying to pull data on a given schedule, put a timer in and just call the webserver every 3 minutes or whatever the requirement is.
If you want to be able to check things (when the app is closed) or if there's rarely fresh data on the server, then you'd need to implement a Push mechanism.
Update: Here's a good article on dealing with the timeout issue - http://blog.xyzzer.me/2011/03/10/real-time-client-server-communication-on-windows-phone-with-long-polling/
Update 2: What if you arranged it so that, you have cascading connections - what I mean is since you can't go beyond 60 seconds per connection, you can write a class that'll house two connections and once one of them is about to timeout, say several seconds before, you can start opening the other connection - you can pick the timing so that there's at most 5 seconds of overlap between them. This way you could have your always open connection.
Also see what these guys have done with the GChat app, they have their source code available at this link. This may provide a more proper design.