我试图用我的定义文件nnunet.def
扩展pytorch docker image:
Bootstrap: docker
From: pytorch/pytorch:1.4-cuda10.1-cudnn7-runtime
%post
git clone https://github.com/NVIDIA/apex
cd apex
pip install -v --no-cache-dir ./
%runscript
echo "Running nnunet container..."
但是,当我构建这个映像(使用sudo singularity build image.sif nnunet.def
)时,我得到了一个错误,即找不到pip:
...
+ pip install -v --no-cache-dir ./
/.build-script-post: 6: /.build-script-post: pip: not found
FATAL: failed to execute %post proc: exit status 127
FATAL: While performing build: while running engine: while running /usr/local/libexec/singularity/bin/starter: exit status 255
为什么?
更令人惊讶的是,当我直接从这张图片进入一个外壳时:
singularity shell docker://pytorch/pytorch:1.4-cuda10.1-cudnn7-runtime
我使用pip没有问题:
Singularity> pip freeze
asn1crypto==1.2.0
backcall==0.1.0
...
为什么我不能在我的定义文件的%post
部分使用pip
简短回答:
%post
中$PATH
的值与在shell中运行时不同,因此它不知道在哪里查找如果查看docker或singularity图像中pip的位置(
which pip
),它位于/opt/conda/bin/pip
。%post
中使用的默认路径是/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
当您看到一个错误,指出命令在作为脚本的一部分运行时不可用,但在以交互方式运行时可用,这几乎总是一个环境问题,
PATH
、PYTHONPATH
、PERL5LIB
等是常见的问题如果将
export PATH=/opt/conda/bin:$PATH
添加到%post
块的开头,应该可以解决此问题相关问题 更多 >
编程相关推荐