3

I have an agent which is trying to lear an upswing with an inverted pendulum on a cart. This takes ages on my Notebook. Then I found Google Colab. I thought this is my golden ticket for fast learning. But when I start my code and close my laptop it doesn't continue overnight. How can I change this? I read about the maximum time you have on the server, but I´m nowhere near this limit. Do I have to include some type of activation or am I just dumb?

CodeBlooded
  • 482
  • 8
  • 15
  • Possible duplicate of: [this](https://stackoverflow.com/questions/57113226/how-to-prevent-google-colab-from-disconnecting) – CodeBlooded May 26 '21 at 10:46

2 Answers2

2

Run the following code in the console and it will prevent you from disconnecting. Ctrl+ Shift + i to open inspector view . Then go to console.

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

Also, there are many methods described here. You can try with these methods.

ashraful16
  • 2,742
  • 3
  • 11
  • 32
2

Well there are tons of different ways of doing this:

  1. Right click on the colaboratory or open Inspect element of your browser. This might vary upon various browsers, so I suggest to search the keyboard shortcut for inspecting element of your browser, might be "Ctrl+Shift+i".....
  2. Navigate and go to console panel of the inspect element window, type this on the console:
function ConnectButton(){
    console.log("Connect pushed"); 
    document.querySelector("#top-toolbar > colab-connect-button").shadowRoot.querySelector("#connect").click() 
}
setInterval(ConnectButton,60000);

What this does is that clicks on the Connect button every 60 seconds of idleness and you should be good to go....BUT You can also click on runtime tab of colaboratory, click on change runtime type, and use Google's dedicated GPU or TPU as this will dramatically increase training process. Good luck!

shakhyar.codes
  • 218
  • 4
  • 14
  • 1
    Thank you for your response :) So when I add GPU compatibly to my code I can use the ones on Colab? Is it the same code for the TPU´s? Is there a tutorial on Colab to use them ? – fabiprogramiert Aug 26 '20 at 17:00
  • 1
    @fabiprogramiert you don't need to change anything on your code! This is made for research purposes only by a lot of extremely professional programmers, and you will not need to install anything to run on Gpu or tpu! They are hardware accelerators to your code... Yes you can use TPU as well! Cheers:-) – shakhyar.codes Aug 27 '20 at 15:50
  • 1
    Super cool :) I´m using your function since and it is super easy to train Models – fabiprogramiert Aug 28 '20 at 09:51