![](/img/trans.png)
[英]Connect to Google Compute Engine instance to run Python script
[英]Connect Google colab to a runtime on a Google Compute Engine instance
我正在尝试将 Google colab 上的 jupyter 笔记本连接到 GCP EC2 实例上的运行时。 我按照这个 colab 文档说明链接
采取的步骤:
在我的本地设置 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 notebook 和 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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.