我最近构建了一个可在Google Colaboratory上运行的Python程序,我需要每天在特定时间运行该程序,那么有什么办法可以安排它在Google Colab上运行?
I recently have built a Python program that runs on Google Colaboratory, I need to run the program every day at a specific time, So Is there any way to schedule it to run on Google Colab?
推荐答案您需要创建一个列出所有协作URL的 notebooks.csv .然后使用 colabctl 运行每个笔记本(依次在CSV中同步提及),然后暂停n秒钟,然后再次运行它们.
You need to create a notebooks.csv listing all the Colaboratory URLs. Then use colabctl to run each notebook (In order, synchronously mentioned in the CSV) and then pauses for a period of n seconds of time before running them again.
然后您可以运行 python colabctl.py< end-string>< sleep-seconds> ,
回购中有一个 gCookies.pkl 文件.确保您的本地Python版本与用于创建此序列化pkl文件的版本相同.
There's a gCookies.pkl file in the repo. Ensure that your local Python version is the same one as used to create this serialized pkl file.
参考: github/TensorTom/colabctl
现在我们已经准备好笔记本和脚本,接下来是能够通过SSH进入Google colab.
Now that we have a notebook and script ready, next is to be able to SSH into Google colab.
- 在ngrok上创建帐户
- 将以下代码复制并粘贴到colab中,该代码将安装ngrok并为我们创建隧道
来源: gist.github/yashkumaratri/204755a85977586cebbb58dc971496da#file-google-colab-ssh
- 现在,在本地计算机上,打开终端和SSH以连接到Colab系统.
ssh root@0.tcp.ngrok.io -p< port_num_generation_above>
现在,您可以通过SSH终端访问整个系统.并且可以继续对本地环境中的任何其他玉米脚本使用colabctl来执行您的远程colab脚本.
Now you have access to the whole system through SSH terminal. And can continue to use colabctl to any other corn script on local environment to execute your remote colab script.
更多推荐
每天在特定时间运行Google Colab
发布评论