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

mao*_*s.a 5 python jupyter jupyter-notebook singularity-container

我已经构建了一个包含最新 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
Run Code Online (Sandbox Code Playgroud)

#####

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

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

#####

回溯(最近一次调用):文件“/opt/conda/lib/python3.7/site-packages/traitlets/traitlets.py”,第 528 行,在 get value = obj._trait_values[self.name] KeyError: '运行时目录'

在处理上述异常的过程中,又发生了一个异常:

回溯(最近一次调用最后一次):

文件“/opt/conda/bin/jupyter-notebook”,第 11 行,在 sys.exit(main()) 中

文件“/opt/conda/lib/python3.7/site-packages/jupyter_core/application.py”,第266行,在launch_instance return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)

文件“/opt/conda/lib/python3.7/site-packages/traitlets/config/application.py”,第657行,在launch_instance app.initialize(argv)

文件“”,第 2 行,在初始化中

文件“/opt/conda/lib/python3.7/site-packages/traitlets/config/application.py”,第87行,catch_config_error返回方法(app,*args,**kwargs)

初始化 self.init_configurables() 中的文件“/opt/conda/lib/python3.7/site-packages/notebook/notebookapp.py”,第 1626 行

文件“/opt/conda/lib/python3.7/site-packages/notebook/notebookapp.py”,第 1319 行,在 init_configurables connection_dir=self.runtime_dir 中,

文件“/opt/conda/lib/python3.7/site-packages/traitlets/traitlets.py”,第556行,在get return self.get(obj, cls)

文件“/opt/conda/lib/python3.7/site-packages/traitlets/traitlets.py”,第535行,在get value = self._validate(obj, dynamic_default())

文件“/opt/conda/lib/python3.7/site-packages/jupyter_core/application.py”,第 99 行,在 _runtime_dir_default ensure_dir_exists(rd, mode=0o700)

文件“/opt/conda/lib/python3.7/site-packages/jupyter_core/utils/ INIT py”为13行,在ensure_dir_exists os.makedirs(路径,模式=模式)

文件“/opt/conda/lib/python3.7/os.py”,第 211 行,在 makedirs 中 makedirs(head,exist_ok=exist_ok)

文件“/opt/conda/lib/python3.7/os.py”,第 211 行,在 makedirs 中 makedirs(head,exist_ok=exist_ok)

文件“/opt/conda/lib/python3.7/os.py”,第 221 行,在 makedirs mkdir(name, mode)

OSError: [Errno 30] 只读文件系统: '/run/user'

#####

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

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

谢谢

小智 4

我刚刚遇到了同样的问题,这似乎已经为我解决了:将/run/user容器内部映射到外部的工作目录(或您选择的目录)。对于你的情况,可能意味着:

singularity exec --bind /path/outside/image/:/path/inside/image/ --bind $PWD:/run/user jupyter.sif jupyter notebook --notebook-dir=/path/to/dir --no-browser --ip=127.0.0.1
Run Code Online (Sandbox Code Playgroud)

像这样运行时,在我的例子中1000创建了一个文件夹