如何使用奇点图像运行 jupyter notebook?

我已经构建了一个包含最新 anaconda 版本的奇异图像 (jupyter.sif),我想用它来运行 jupyter notebook。


我想运行这样的东西:


singularity exec \

  --bind /path/outside/image/:/path/inside/image/ \

  jupyter.sif jupyter notebook \

    --notebook-dir=/path/to/dir --no-browser --ip=127.0.0.1

本质上,只需启动一个普通的 jupyter notebook,它将使用 python 版本和安装在奇异图像中的包。理想情况下,笔记本将读取和写入图像外的文件(因此我指定了绑定路径)。


但是,当我运行上述命令时,出现以下错误:


> Traceback (most recent call last):   File

> "/opt/conda/lib/python3.7/site-packages/traitlets/traitlets.py", line

> 528, in get

>     value = obj._trait_values[self.name] KeyError: 'runtime_dir'

> During handling of the above exception, another exception occurred:

> Traceback (most recent call last):

>   File "/opt/conda/bin/jupyter-notebook", line 11, in <module>

>     sys.exit(main())

>   File

> "/opt/conda/lib/python3.7/site-packages/jupyter_core/application.py",

> line 266, in launch_instance

>     return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)

>   File

> "/opt/conda/lib/python3.7/site-packages/traitlets/config/application.py",

> line 657, in launch_instance

>     app.initialize(argv)

>   File "<decorator-gen-7>", line 2, in initialize

>   File

> "/opt/conda/lib/python3.7/site-packages/traitlets/config/application.py",

> line 87, in catch_config_error

>     return method(app, *args, **kwargs)

>   File

> "/opt/conda/lib/python3.7/site-packages/notebook/notebookapp.py", line

> 1626, in initialize

>     self.init_configurables()

>   File

> "/opt/conda/lib/python3.7/site-packages/notebook/notebookapp.py", line

> 1319, in init_configurables

>     connection_dir=self.runtime_dir,

>   File

> "/opt/conda/lib/python3.7/site-packages/traitlets/traitlets.py", line

> 556, in __get__

>     return self.get(obj, cls)

我认为这是因为笔记本试图在图像中写入内容,并且因为我没有将图像作为 sudo 运行(我不想这样做)并且我在执行图像时也没有指定 --writable (也不想这样做),它抱怨无法在图像中写入。


有没有办法“告诉”图像在我的主目录中而不是在图像内部读取和写入文件?


翻翻过去那场雪
浏览 200回答 3
3回答

MMMHUHU

我刚刚遇到了同样的问题,这似乎已经为我解决了:将容器内的 /run/user 映射到外部工作目录(或您选择的目录)。对于您的情况,可能意味着:singularity&nbsp;exec&nbsp;--bind&nbsp;/path/outside/image/:/path/inside/image/&nbsp;--bind&nbsp;$PWD:/run/user&nbsp;jupyter.sif&nbsp;jupyter&nbsp;notebook&nbsp;--notebook-dir=/path/to/dir&nbsp;--no-browser&nbsp;--ip=127.0.0.1像这样运行时,在我的情况下1000创建了一个文件夹

拉丁的传说

这适用于奇点实例,例如:&nbsp;&nbsp;&nbsp;singularity&nbsp;instance.start&nbsp;--writable&nbsp;--contain&nbsp;--bind&nbsp;shared:/shared&nbsp;sandbox/&nbsp;jupyter

DIEA

该接受的答案的作品,但这里是不需要绑定安装另一种解决方案。可以unset XDG_RUNTIME_DIR在运行jupyter notebook之前运行,这个错误就会消失。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python