【问题标题】:Connect google cloud to google colab将谷歌云连接到谷歌 colab
【发布时间】:2021-10-05 19:31:50
【问题描述】:

我一周以来一直在尝试将我的 google colab notebook 与谷歌云连接,但在谷歌云终端中执行以下步骤:

1) gcloud init and then choose the appropriate settings
2) gcloud compute ssh --zone us-central1-a 'name' -- -L 8888:localhost:8888  
3) one of these lines
jupyter notebook  --NotebookApp.allow_origin='https://colab.research.google.com'  --port=8888  --NotebookApp.port_retries=0 --no-browser, or 
jupyter notebook  --NotebookApp.allow_origin='https://colab.research.google.com'  --port=8888  --NotebookApp.port_retries=0 

输出看起来像这样

然后我将 url 复制粘贴到 google colab 的本地运行时,错误是这样的

我再次按照这些步骤操作,但我仍然遇到同样的问题。你知道如何克服这个问题吗?我认为这是基于我的计算机的问题。

请注意,我关闭了 addblocker。

【问题讨论】:

    标签: python google-cloud-platform


    【解决方案1】:

    我尝试复制设置,并且能够将 Google Colab 连接到 Google Cloud。

    • 使用连接到服务器后,

      gcloud compute ssh --zone us-central1-a 'instance-name' -- -L 8888:localhost:8888
      
    • 使用以下命令安装并设置必要的库以连接到 Colab 前端:

      pip install jupyter_http_over_ws
      jupyter serverextension enable --py jupyter_http_over_ws
      jupyter notebook --NotebookApp.allow_origin='https://colab.research.google.com'  --port=8888 --NotebookApp.port_retries=0  --no-browser
      
    • 要连接到 Colab 前端,我们会得到一个 URL 作为上述命令的输出。

    • 当您在终端中单击 URL 时,它将成功重定向到 Jupyter 主页,没有任何问题。

    更多信息请参考Colab+GCP Compute — how to link them together

    【讨论】:

    • 非常感谢,我几天前就知道了。我还有一个问题,由于某种原因,我的 linux rever 包含 python 3.7,但使用的是 python 2.7。你知道如何改变吗?
    【解决方案2】:

    实际上,我犯了一个非常愚蠢的基本错误。首先你的服务器应该是linux的,然后在windows命令中写下如下代码:

    cloud compute ssh colab-backend --zone=europe-west4-a -L 8080:locahost:8081,改成你项目所在的zone和port

    type jupyter notebook --NotebookApp.allow_origin='https://colab.research.google.com' --port=8888 --NotebookApp.port_retries=0 --no-browser

    将链接复制到您的 google colab 中的“本地运行时”中。

    【讨论】:

      猜你喜欢
      • 2021-10-06
      • 2019-05-23
      • 2021-06-13
      • 2020-04-13
      • 1970-01-01
      • 2021-10-18
      • 2020-09-29
      • 2020-08-18
      • 2021-01-25
      相关资源
      最近更新 更多