当前位置: 首页 > 知识库问答 >
问题:

在docker容器内启动jupyter时出错

唐腾
2023-03-14

我成功地在ubuntu 18.04上安装了docker和nvidia-docker,我从NVIDIA的GPU云中提取了这个图像

https://ngc.nvidia.com/catalog/containers/nvidia:caffe

用这个命令运行它

nvidia-docker run -it --rm -v /home/stefan/Dropbox:/data -p 8888:8888 nvcr.io/nvidia/caffe:19.03-py2 sh

例如,容器给了我一个shell提示,它似乎可以工作

# nvidia-smi

导致

Sat Mar 30 21:03:30 2019       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 418.39       Driver Version: 418.39       CUDA Version: 10.1     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 105...  On   | 00000000:01:00.0  On |                  N/A |
| 20%   30C    P8    N/A /  75W |    441MiB /  4038MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|

它看到了我脆弱的gpu。我尝试用这个命令运行jupyter

#jupyter-notebook

但我明白了

[I 21:05:18.088 NotebookApp] Writing notebook server cookie secret to /root/.local/share/jupyter/runtime/notebook_cookie_secret
Traceback (most recent call last):
  File "/usr/local/bin/jupyter-notebook", line 10, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/jupyter_core/application.py", line 266, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/traitlets/config/application.py", line 657, in launch_instance
    app.initialize(argv)
  File "</usr/local/lib/python2.7/dist-packages/decorator.pyc:decorator-gen-7>", line 2, in initialize
  File "/usr/local/lib/python2.7/dist-packages/traitlets/config/application.py", line 87, in catch_config_error
    return method(app, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/notebook/notebookapp.py", line 1628, in initialize
    self.init_webapp()
  File "/usr/local/lib/python2.7/dist-packages/notebook/notebookapp.py", line 1407, in init_webapp
    self.http_server.listen(port, self.ip)
  File "/usr/local/lib/python2.7/dist-packages/tornado/tcpserver.py", line 143, in listen
    sockets = bind_sockets(port, address=address)
  File "/usr/local/lib/python2.7/dist-packages/tornado/netutil.py", line 168, in bind_sockets
    sock.bind(sockaddr)
  File "/usr/lib/python2.7/socket.py", line 228, in meth
    return getattr(self._sock,name)(*args)
socket.error: [Errno 99] Cannot assign requested address

我知道Jupyter安装在容器里因为当我打字的时候

#jupyter --version

我得到

4.4.0

打字

# jupyter

给予

usage: jupyter [-h] [--version] [--config-dir] [--data-dir] [--runtime-dir]
               [--paths] [--json]
               [subcommand]
jupyter: error: one of the arguments --version subcommand --config-dir --data-dir --runtime-dir --paths is required

在连接到容器的主机目录中,我有几个笔记本

# ls
NBA.ipynb  exponents.ipynb        hello_deep_learning-master    

但似乎什么都没用

# jupyter NBA.ipynb

Error executing Jupyter command 'NBA.ipynb': [Errno 2] No such file or directory


# jupyter notebook NBA.ipynb

Traceback (most recent call last):
  File "/usr/local/bin/jupyter-notebook", line 10, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/jupyter_core/application.py", line 266, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/traitlets/config/application.py", line 657, in launch_instance
    app.initialize(argv)
  File "</usr/local/lib/python2.7/dist-packages/decorator.pyc:decorator-gen-7>", line 2, in initialize
  File "/usr/local/lib/python2.7/dist-packages/traitlets/config/application.py", line 87, in catch_config_error
    return method(app, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/notebook/notebookapp.py", line 1628, in initialize
    self.init_webapp()
  File "/usr/local/lib/python2.7/dist-packages/notebook/notebookapp.py", line 1407, in init_webapp
    self.http_server.listen(port, self.ip)
  File "/usr/local/lib/python2.7/dist-packages/tornado/tcpserver.py", line 143, in listen
    sockets = bind_sockets(port, address=address)
  File "/usr/local/lib/python2.7/dist-packages/tornado/netutil.py", line 168, in bind_sockets
    sock.bind(sockaddr)
  File "/usr/lib/python2.7/socket.py", line 228, in meth
    return getattr(self._sock,name)(*args)
socket.error: [Errno 99] Cannot assign requested address


# jupyter-notebook NBA.ipynb

Traceback (most recent call last):
  File "/usr/local/bin/jupyter-notebook", line 10, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/jupyter_core/application.py", line 266, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/traitlets/config/application.py", line 657, in launch_instance
    app.initialize(argv)
  File "</usr/local/lib/python2.7/dist-packages/decorator.pyc:decorator-gen-7>", line 2, in initialize
  File "/usr/local/lib/python2.7/dist-packages/traitlets/config/application.py", line 87, in catch_config_error
    return method(app, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/notebook/notebookapp.py", line 1628, in initialize
    self.init_webapp()
  File "/usr/local/lib/python2.7/dist-packages/notebook/notebookapp.py", line 1407, in init_webapp
    self.http_server.listen(port, self.ip)
  File "/usr/local/lib/python2.7/dist-packages/tornado/tcpserver.py", line 143, in listen
    sockets = bind_sockets(port, address=address)
  File "/usr/local/lib/python2.7/dist-packages/tornado/netutil.py", line 168, in bind_sockets
    sock.bind(sockaddr)
  File "/usr/lib/python2.7/socket.py", line 228, in meth
    return getattr(self._sock,name)(*args)
socket.error: [Errno 99] Cannot assign requested address

我认为这是语法问题,因为这行得通

  docker run -it --rm -v ~/Dropbox:/tf/notebooks -p 8888:8888 tensorflow/tensorflow:latest-py3-jupyter

它在容器中启动jupyter服务器,在浏览器中,我可以在127.0.0.1打开一个笔记本,其中显示一个目录,我可以在其中看到一个名为“笔记本”的文件夹,其中包含我的Dropbox内容。正如预期的那样,因为我在上面的命令中将dropbox文件夹作为卷装入。

但是如果我打这个

  docker run -it --rm -v ~/Dropbox:/tf/notebooks -p 8888:8888 tensorflow/tensorflow:latest-py3-jupyter sh

我在一个壳,但不能启动jupyter。我得到了相同的错误,因为我之前与nvcr.io/nvidia/caffe图像。如何在运行docker容器shell后启动jupyter?

共有1个答案

沃威
2023-03-14

我想我明白了。在容器的shell提示符下,我键入

jupyter notebook --ip=0.0.0.0 --allow-root

我会把这个留在这里,以防像我这样的新手有类似的问题。(除非版主觉得应该编辑或核)

 类似资料:
  • 问题内容: 在永久启动Docker容器中启动节点时,如果我手动启动时出现问题,而是在构建和启动容器时退出Dockerfile中的同一命令,则退出了。该命令在bash中有效: 我试图将命令放入Dockerfile中,但容器未启动 问题答案: Google网上论坛讨论 在后台运行。要在前台运行,请尝试。 这永远从前台开始,这正是Docker需要的。请记住,只有在CMD中定义的过程启动并运行时,容器才是

  • 问题内容: 我使用以下命令创建了容器: 以下是命令: 真的没有太多要说的,我希望容器能启动并保持正常运行。这是日志: 问题答案: 您正在尝试运行,它是需要tty 才能运行的交互式外壳。使用,在“分离”模式下运行此命令实际上没有任何意义,但是您可以通过添加到命令行来做到这一点,以确保容器具有与其关联的有效tty并保持连接状态: 在启动分离的容器时,您通常会运行某种长期存在的非交互式进程(例如,或We

  • 当我运行以下命令时,我将得到错误: 检测到体系结构x86-64。将主机名设置为。 正在从随机生成器初始化机器ID。 无法移动剩余的userspace进程,忽略:输入/输出错误

  • 出于对它的热爱,我不能从Docker容器中启动Jupyter。我的操作系统: Dockerfile: 文件只是 Docker映像是通过以下命令轻松构建的: 我运行的容器 我得到以下错误: 发生了什么事?我将Jupyter笔记本端口(8888)映射到一个容器端口(6067),因此我不明白问题出在哪里。

  • 问题内容: 我想在Centos7的Docker容器中运行Jenkins。我看到了Jenkins的官方文档:首先,从Docker存储库中提取官方的jenkins映像。 接下来,使用该映像运行一个容器,并将数据目录从该容器映射到主机;例如,在下面的示例中,容器中的/ var / jenkins_home从主机上的当前路径映射到jenkins /目录。Jenkins 8080端口也以49001的身份向主

  • 我想做的是,在运行compose up之后,在我的web本地主机中看到一个简单的html文件。但我在localhost的8080 8000 8009端口中看不到任何东西。 当我将yml更改为 上面写着 caner@vegan:~/ideaprojects/combabety$pwd/home/caner/ideaprojects/combabety$ls docker-compose.yml ht