如何防止 Google Colab 断开连接? [英] How to prevent Google Colab from disconnecting?

查看:62
本文介绍了如何防止 Google Colab 断开连接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问:有没有办法以编程方式阻止

以下描述了导致笔记本自动断开连接的情况:

<块引用>

Google Colab 笔记本的空闲超时时间为 90 分钟,绝对超时时间为 12 小时.这意味着,如果用户超过 90 分钟未与其 Google Colab 笔记本交互,其实例将自动终止.此外,Colab 实例的最长生命周期为 12 小时.

当然,我们希望自动从实例中挤出最大值,而无需手动与它不断.在这里,我将假设常见的系统要求:

  • Ubuntu 18 LTS/Windows 10/Mac 操作系统
  • 如果是基于 Linux 的系统,请使用 Gnome 3 或 Unity 等流行的 DE
  • Firefox 或 Chromium 浏览器

我应该在此指出,此类行为不违反 Google Colab 的条款使用,尽管根据他们的常见问题解答(简而言之:从道德上讲,如果您真的不需要它,则用完所有 GPU 是不行的).

<小时>

我目前的解决方案非常愚蠢:

  • 首先,我关闭了屏幕保护程序,这样我的屏幕就一直亮着.
  • 我有一个 Arduino 板,所以我把它变成了 橡胶鸭子 USB 并让它在我睡觉时模拟原始用户交互(只是因为我手头有其他用例).

有更好的方法吗?

解决方案

Edit 2:截至 2021 年 3 月,这些方法均无效,因为谷歌添加了一个验证码按钮,该按钮会在一段时间后随机弹出.

编辑 1:显然,该解决方案非常简单,并且不需要任何 JavaScript.只需在底部创建一个具有以下行的新单元格:

while True:pass

现在将单元格保持在运行序列中,这样无限循环就不会停止,从而使您的会话保持活动状态.

旧方法:设置 javascript 间隔以每 60 秒单击一次连接按钮.使用 Ctrl+Shift+I 打开开发人员设置(在您的网络浏览器中),然后单击控制台选项卡并在控制台提示中键入.(对于 Mac,请按 Option+Command+I)

function ConnectButton(){console.log(连接推送");document.querySelector("#top-toolbar > colab-connectbutton").shadowRoot.querySelector("#connect").click()}setInterval(ConnectButton,60000);

Q: Is there any way to programmatically prevent Google Colab from disconnecting on a timeout?

The following describes the conditions causing a notebook to automatically disconnect:

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.

Naturally, we want to automatically squeeze the maximum out of the instance, without having to manually interact with it constantly. Here I will assume commonly seen system requirements:

  • Ubuntu 18 LTS / Windows 10 / Mac Operating systems
  • In case of Linux-based systems, using popular DEs like Gnome 3 or Unity
  • Firefox or Chromium browsers

I should point out here that such behavior does not violate Google Colab's Terms of Use, although it is not encouraged according to their FAQ (in short: morally it is not okay to use up all of the GPUs if you don't really need it).


My current solution is very dumb:

  • First, I turn the screensaver off, so my sreen is always on.
  • I have an Arduino board, so I just turned it into a rubber ducky usb and make it emulate primitive user interaction while I sleep (just because I have it at hand for other use-cases).

Are there better ways?

解决方案

Edit 2: As of March 2021, none of these methods will work as google added a captcha button that randomly pops up after some time.

Edit 1: Apparently the solution is very easy, and doesn't need any JavaScript. Just create a new cell at the bottom having the following line:

while True:pass

now keep the cell in the run sequence so that the infinite loop won't stop and thus keep your session alive.

Old method: Set a javascript interval to click on the connect button every 60 seconds. Open developer-settings (in your web-browser) with Ctrl+Shift+I then click on console tab and type this on the console prompt. (for mac press Option+Command+I)

function ConnectButton(){
  console.log("Connect pushed"); 
  document.querySelector("#top-toolbar > colab-connectbutton").shadowRoot.querySelector("#connect").click() 
}
setInterval(ConnectButton,60000);

这篇关于如何防止 Google Colab 断开连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆