powershell - 如何在 Windows 10 上使用 Powershell 将 Google Colab 与本地 TensorFlow Jupyter 服务器结合使用?

标签 powershell docker tensorflow jupyter-notebook google-colaboratory

我正在尝试使用 Docker 在 Windows 10 上学习 TensorFlow,但我陷入了环境设置的最开始阶段。

我遵循了这个: https://www.tensorflow.org/install#download-a-package

并且做到了:

docker run -it -p 8888:8888 tensorflow/tensorflow:latest-py3-jupyter

然后我遵循了这个: https://www.tensorflow.org/tutorials/quickstart/beginner

问题是当我尝试使用 Google Colab(使用 Google Chrome)连接到本地服务器时,我在 docker 日志中收到以下错误:

Blocking Cross Origin API request for /http_over_websocket. Origin: https://colab.research.google.com, Host: localhost:8888

错误非常明显,Google Colab 立即给了我解决方案:

jupyter notebook \
--NotebookApp.allow_origin='https://colab.research.google.com' \ --port=8888 \ --NotebookApp.port_retries=0

但是,对于我的一生,我无法弄清楚如何将此参数添加到 docker 镜像/容器/命令/配置...

到目前为止我尝试过的:

  1. 我尝试将参数传递给 docker run 命令,但不起作用。
  2. 我尝试在不使用 -it 的情况下运行容器,然后连接到它以使用这些参数重新启动服务器,但是一旦我停止 Jupyter 服务器,它就会停止 docker。
  3. 我尝试在启动 docker 时指定“-u $(id -u):$(id -g)”,因为我在容器启动时收到警告,提示我不应以 root 用户身份进行连接。 .但它不起作用,因为我在 Windows 10 上使用 PowerShell。

如有任何帮助,我们将不胜感激:)

最佳答案

好吧,经过几个小时的搜索,我发现了如何覆盖 docker 镜像默认 CMD 来附加“--NotebookApp.allow_origin=' https://colab.research.google.com '”,并且成功了!

所以解决办法是:

docker run -it -p 8888:8888 tensorflow/tensorflow:latest-py3-jupyter jupyter notebook --notebook-dir=/tf --ip 0.0.0.0 --no-browser --allow-root --NotebookApp.allow_origin='https://colab.research.google.com'

关于powershell - 如何在 Windows 10 上使用 Powershell 将 Google Colab 与本地 TensorFlow Jupyter 服务器结合使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61024722/

相关文章:

ubuntu - 安装特定版本的 docker

php - Dockerfile - RUN apt-get install -y php5-MODULES 不再工作 -'has no installation candidate' 。如何解决?

node.js - 在 Docker 中构建时出现 node-sass 错误

python - 根据条件从另一个张量创建一个张量

python - TensorFlow embedding_rnn_decoder 'Tensor' 对象不可迭代

file - CMDExec如果存在则停止

windows - 文件夹上的 Powershell Remove-Item 仅在通过 Ansible 运行时失败

powershell - 复制项目默认覆盖

windows - 启动 PowerShell session 时出错

python - 如何在另一台计算机上打开 Tensorflow 保护程序