我正在尝试将 Google colab 上的 jupyter notebook 连接到 GCP EC2 实例上的运行时。我按照这个 colab doc 说明链接
采取的步骤:
在我的本地设置 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
Run Code Online (Sandbox Code Playgroud)
在 GCP 上创建并启动 EC2 实例
SSH 到 EC2 实例并使用以下方法转发本地端口:
gcloud beta compute ssh --zone "europe-west2-c" "<ec2-instance-name>" --project "<project-name>" -- -L 8888:localhost:8888
Run Code Online (Sandbox Code Playgroud)
尝试转发端口的错误消息:
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.
Run Code Online (Sandbox Code Playgroud)
我还尝试将 ec2 实例直接连接到 colab,但我无法连接。对于最后一步,我假设将 Jupyter url …
python ssh google-cloud-platform jupyter-notebook google-colaboratory