将 Google Colab 与本地运行时连接时出错

Posted

技术标签:

【中文标题】将 Google Colab 与本地运行时连接时出错【英文标题】:Error connecting Google Colab with local runtime 【发布时间】:2021-09-25 10:09:17 【问题描述】:

作为local rutimes 的说明 我已经从 conda install -c conda-forge jupyter_http_over_ws

安装了 jupyter_http_over_ws 扩展

然后我启动并验证了服务器,并将命令提示符的链接粘贴到协作本地运行时选项,


(base) C:\Windows\system32>jupyter serverextension enable --py jupyter_http_over
_ws
Config option `kernel_spec_manager_class` not recognized by `EnableServerExtensi
onApp`.
Enabling: jupyter_http_over_ws
- Writing config: C:\Users\Abhilash Singh Chauh\.jupyter
    - Validating...
      jupyter_http_over_ws 0.0.7 ok

(base) C:\Windows\system32>jupyter notebook \  --NotebookApp.allow_origin='https
://colab.research.google.com' \  --port=8888 \  --NotebookApp.port_retries=0
[I 20:47:47.662 NotebookApp] [nb_conda_kernels] enabled, 2 kernels found
jupyter_http_over_ws extension initialized. Listening on /http_over_websocket
[I 20:47:48.258 NotebookApp] JupyterLab extension loaded from C:\ProgramData\Ana
conda3\lib\site-packages\jupyterlab
[I 20:47:48.258 NotebookApp] JupyterLab application directory is C:\ProgramData\
Anaconda3\share\jupyter\lab
[I 20:47:48.269 NotebookApp] [nb_conda] enabled
[I 20:47:48.270 NotebookApp] Serving notebooks from local directory: C:\
[I 20:47:48.271 NotebookApp] The Jupyter Notebook is running at:
[I 20:47:48.271 NotebookApp] http://localhost:8888/?token=10ee1d9aa2bd471430f0cd
6998eb3d281d392ad0cc6a114b
[I 20:47:48.271 NotebookApp]  or http://127.0.0.1:8888/?token=10ee1d9aa2bd471430
f0cd6998eb3d281d392ad0cc6a114b
[I 20:47:48.272 NotebookApp] Use Control-C to stop this server and shut down all
 kernels (twice to skip confirmation).
[C 20:47:48.338 NotebookApp]

    To access the notebook, open this file in a browser:
        file:///C:/Users/Abhilash%20Singh%20Chauh/AppData/Roaming/jupyter/runtim
e/nbserver-9576-open.html
    Or copy and paste one of these URLs:
        http://localhost:8888/?token=10ee1d9aa2bd471430f0cd6998eb3d281d392ad0cc6
a114b
     or http://127.0.0.1:8888/?token=10ee1d9aa2bd471430f0cd6998eb3d281d392ad0cc6
a114b

但它没有连接。 但是,故障排除选项也没有显示任何错误,

[I 20:48:11.359 NotebookApp] 302 GET /?token=10ee1d9aa2bd471430f0cd6998eb3d281d3
92ad0cc6%20a114b (::1) 1.00ms
[I 20:48:11.370 NotebookApp] 302 GET /tree?token=10ee1d9aa2bd471430f0cd6998eb3d2
81d392ad0cc6%20a114b (::1) 2.00ms
[W 20:48:11.419 NotebookApp] Forbidden
[W 20:48:11.420 NotebookApp] 403 GET /api/kernelspecs (::1) 2.00ms referer=None
[I 20:48:22.846 NotebookApp] 302 GET /?token=10ee1d9aa2bd471430f0cd6998eb3d281d3
92ad0cc6%20a114b (::1) 1.00ms
[I 20:48:22.854 NotebookApp] 302 GET /tree?token=10ee1d9aa2bd471430f0cd6998eb3d2
81d392ad0cc6%20a114b (::1) 1.00ms
[W 20:48:22.868 NotebookApp] Forbidden
[W 20:48:22.869 NotebookApp] 403 GET /api/kernelspecs (::1) 2.00ms referer=None
[I 20:48:28.745 NotebookApp] 302 GET /?token=10ee1d9aa2bd471430f0cd6998eb3d281d3
92ad0cc6%20a114b (::1) 2.00ms
[I 20:48:28.804 NotebookApp] 302 GET /tree?token=10ee1d9aa2bd471430f0cd6998eb3d2
81d392ad0cc6%20a114b (::1) 1.00ms
[W 20:48:28.859 NotebookApp] Forbidden
[W 20:48:28.860 NotebookApp] 403 GET /api/kernelspecs (::1) 2.00ms referer=None
[I 20:49:25.858 NotebookApp] 302 GET /?token=10ee1d9aa2bd471430f0cd%206998eb3d28
1d392ad0cc6a114b (::1) 1.00ms
[I 20:49:25.870 NotebookApp] 302 GET /tree?token=10ee1d9aa2bd471430f0cd%206998eb
3d281d392ad0cc6a114b (::1) 4.00ms
[W 20:49:25.888 NotebookApp] Forbidden
[W 20:49:25.889 NotebookApp] 403 GET /api/kernelspecs (::1) 1.00ms referer=None
[I 20:49:34.336 NotebookApp] 302 GET /?token=10ee1d9aa2bd471430f0cd%206998eb3d28
1d392ad0cc6a114b (::1) 1.00ms
[I 20:49:34.343 NotebookApp] 302 GET /tree?token=10ee1d9aa2bd471430f0cd%206998eb
3d281d392ad0cc6a114b (::1) 1.00ms
[W 20:49:34.363 NotebookApp] Forbidden
[W 20:49:34.364 NotebookApp] 403 GET /api/kernelspecs (::1) 1.98ms referer=None
[I 20:50:13.715 NotebookApp] 302 GET /?token=10ee1d9aa2bd471430f0cd%206998eb3d28
1d392ad0cc6a114b (::1) 1.00ms
[I 20:50:13.722 NotebookApp] 302 GET /tree?token=10ee1d9aa2bd471430f0cd%206998eb
3d281d392ad0cc6a114b (::1) 1.00ms
[W 20:50:13.738 NotebookApp] Forbidden
[W 20:50:13.739 NotebookApp] 403 GET /api/kernelspecs (::1) 2.00ms referer=None
[I 20:50:27.850 NotebookApp] 302 GET /?token=10ee1d9aa2bd471430f0cd%206998eb3d28
1d392ad0cc6a114b (::1) 1.00ms
[I 20:50:27.855 NotebookApp] 302 GET /tree?token=10ee1d9aa2bd471430f0cd%206998eb
3d281d392ad0cc6a114b (::1) 1.00ms
[W 20:50:27.876 NotebookApp] Forbidden
[W 20:50:27.877 NotebookApp] 403 GET /api/kernelspecs (::1) 3.00ms referer=None
[I 20:50:29.330 NotebookApp] 302 GET /?token=10ee1d9aa2bd471430f0cd%206998eb3d28
1d392ad0cc6a114b (::1) 1.00ms
[I 20:50:29.337 NotebookApp] 302 GET /tree?token=10ee1d9aa2bd471430f0cd%206998eb
3d281d392ad0cc6a114b (::1) 1.01ms
[W 20:50:29.353 NotebookApp] Forbidden
[W 20:50:29.353 NotebookApp] 403 GET /api/kernelspecs (::1) 1.00ms referer=None
[I 20:51:45.484 NotebookApp] 302 GET /?token=10ee1d9aa2bd471430f0cd6998eb3d281d3
92ad0cc6%20a114b (::1) 1.00ms
[I 20:51:45.495 NotebookApp] 302 GET /tree?token=10ee1d9aa2bd471430f0cd6998eb3d2
81d392ad0cc6%20a114b (::1) 2.00ms
[W 20:51:45.509 NotebookApp] Forbidden
[W 20:51:45.510 NotebookApp] 403 GET /api/kernelspecs (::1) 1.00ms referer=None
[I 20:51:59.430 NotebookApp] 302 GET /?token=10ee1d9aa2bd471430f0cd6998eb3d281d3
92ad0cc6%20a114b (::1) 1.00ms
[I 20:51:59.437 NotebookApp] 302 GET /tree?token=10ee1d9aa2bd471430f0cd6998eb3d2
81d392ad0cc6%20a114b (::1) 1.00ms
[W 20:51:59.452 NotebookApp] Forbidden
[W 20:51:59.454 NotebookApp] 403 GET /api/kernelspecs (::1) 2.99ms referer=None
[I 20:53:12.086 NotebookApp] 302 GET /?token=10ee1d9aa2bd471430f0cd%206998eb%203
d281d392ad0cc6a114b (::1) 2.00ms
[I 20:53:12.092 NotebookApp] 302 GET /tree?token=10ee1d9aa2bd471430f0cd%206998eb
%203d281d392ad0cc6a114b (::1) 1.00ms
[W 20:53:12.116 NotebookApp] Forbidden
[W 20:53:12.117 NotebookApp] 403 GET /api/kernelspecs (::1) 4.02ms referer=None

如何解决这个问题。

【问题讨论】:

【参考方案1】:

尝试不使用浏览器打开

jupyter notebook --NotebookApp.allow_origin='https://colab.research.google.com' \ --port=9090 --no-browser

【讨论】:

这没有提供问题的答案。一旦你有足够的reputation,你就可以comment on any post;相反,provide answers that don't require clarification from the asker。 - From Review

以上是关于将 Google Colab 与本地运行时连接时出错的主要内容,如果未能解决你的问题,请参考以下文章

google colab 使用本地运行时并且未检测到本地 gpu

Google Colab 中的本地运行时和托管运行时有啥区别?

google.colab 模块中是不是有关闭运行时的功能

试图在 google colab 上创建与我的本地 mysql 数据库的连接

Google Colab:从本地上传 Pytorch 模型后“无法连接到运行时”

如何防止从运行时断开连接(Google Colab)