将Google CoLab连接到Google Compute Engine实例上的运行时 [英] Connect Google colab to a runtime on a Google Compute Engine instance

查看:25
本文介绍了将Google CoLab连接到Google Compute Engine实例上的运行时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将Google CoLab上的Jupyter笔记本连接到GCP EC2实例上的运行时。我遵循此CoLab文档说明Link

采取的步骤:

  • 在本地设置Jupyter服务器

    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
    
  • 在GCP上创建并启动EC2实例

  • SSH进入EC2实例并使用转发本地端口:

    gcloud beta compute ssh --zone "europe-west2-c" "<ec2-instance-name>" --project "<project-name>" -- -L 8888:localhost:8888
    

尝试转发端口的错误消息:

bind [127.0.0.1]:8888: Address already in use
channel_setup_fwd_listener_tcpip: cannot listen to port: 8888
Could not request local forwarding.

我还尝试将EC2实例直接连接到CoLab,但无法成功。对于最后一步,我假设将jupyter url复制到CoLab本地运行时。我如何修复此问题?

推荐答案

我算出来了。

步骤:

  • 启动实例

  • 连接到实例并将远程实例上的端口转发到本地计算机

    gcloud beta compute ssh --zone "<zone>" "<ec2-instance-name>" --project "<project-name>" -- -L 8888:localhost:8888
    
  • 安装jupyter笔记本和jupyter_http_over_ws(如果未在 远程实例已经。

  • 然后启用jupyter_http_over_ws

    jupyter serverextension enable --py jupyter_http_over_ws
    
  • 在远程实例上启动Jupyter服务器

    jupyter notebook 
     --NotebookApp.allow_origin='https://colab.research.google.com' 
     --port=8888 
     --NotebookApp.port_retries=0
    
  • 将服务器URL复制到CoLab

这篇关于将Google CoLab连接到Google Compute Engine实例上的运行时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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