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

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

问题描述

问:是否可以通过编程方式阻止 Google Colab 超时断开连接?

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笔记本的空闲超时为90分钟,绝对超时为12小时.这意味着,如果用户在超过90分钟的时间内未与其Google Colab笔记本进行互动,则其实例将自动终止.另外,Colab实例的最长生存期为12小时.

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

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操作系统
  • 对于基于Linux的系统,请使用流行的DE,例如Gnome 3或Unity
  • Firefox或Chromium浏览器

我应该在这里指出,这种行为不违反 Google Colab的条款使用,尽管根据他们的常见问题解答(简称:从道德上讲,如果您真的不需要用尽所有GPU,那是不可行的.

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:

  • 首先,我关闭屏幕保护程序,因此屏幕始终保持打开状态.
  • 我有一个Arduino开发板,所以我只是将它变成了橡胶ducky usb 并使其在我睡觉时模拟原始用户交互(只是因为我手头有其他用例).
  • 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).

还有更好的方法吗?

推荐答案

设置JavaScript间隔,每60秒单击一次connect按钮. 使用Ctrl + Shift + I打开开发人员设置(在您的Web浏览器中),然后单击控制台选项卡,然后在控制台提示符下键入此设置. (对于Mac,请按Option + Command + I)

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-connect-button").shadowRoot.querySelector("#connect").click() 
}
setInterval(ConnectButton,60000);

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

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