Skip to content

Instantly share code, notes, and snippets.

@morganmcg1
Last active March 20, 2021 14:57
Show Gist options
  • Save morganmcg1/7efefc5dabac971a8198c3e2f6dd15a6 to your computer and use it in GitHub Desktop.
Save morganmcg1/7efefc5dabac971a8198c3e2f6dd15a6 to your computer and use it in GitHub Desktop.
Colab auto-click, prevent close due to inactivity
In case you want to use this google colab to fine-tune your model, you should make sure that
your training doesn't stop due to inactivity. A simple hack to prevent this is to paste the
following code into the console of this tab (right mouse click -> inspect -> Console tab and insert code).
```
function ConnectButton(){
console.log("Connect pushed");
document.querySelector("#top-toolbar > colab-connect-button").shadowRoot.querySelector("#connect").click()
}
setInterval(ConnectButton,60000);
```
OR:
I’m training on Google Cloud with 2 T4 GPUs, which are quite inexpensive and using screen to keep the code running, even if SSH disconnects for any reason. Steps to run screen properly:
$ script /dev/null
$ screen
ENTER
$ python training.py
CLOSE WINDOW
To check what part of the code is running, SSH again an run:
$ screen -r
3310.pts-6.training
$ screen -d -r 3310
To quit screen:
$ screen -X -S 3310.pts-6.training quit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment