【发布时间】:2020-09-06 02:06:08
【问题描述】:
我正在尝试将 Google colab 上的 jupyter notebook 连接到 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 本地运行时。我该如何解决这个问题?
【问题讨论】:
-
如果你转发到本地主机上的不同端口怎么办?
-
在关闭 jupyter 服务器后通过 SSH 连接到不同端口或同一端口上的实例有效。但我想要做的是将流量从 colab 转发到 jupyter 服务器到 ec2 实例。 @IgorRivin
标签: python ssh google-cloud-platform jupyter-notebook google-colaboratory