我尝试用我的定义文件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 is not found:
...
+ 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为什么?
更令人惊讶的是,当我直接从下面的图像进入一个shell时: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?
发布于 2020-08-28 16:08:56
简而言之:%post中的$PATH值与在shell中运行时的值不同,因此它不知道从哪里查找。
如果您查看pip在docker或奇点图像中的位置(which pip),它位于/opt/conda/bin/pip。%post中使用的默认路径是/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin。
当你看到一个错误,指出命令在作为脚本的一部分运行时不可用,但当你以交互方式运行时,它是可用的,这几乎总是一个环境问题,PATH、PYTHONPATH、PERL5LIB等是常见的罪魁祸首。
如果在%post代码块的开头添加export PATH=/opt/conda/bin:$PATH,应该可以解决这个问题。
https://stackoverflow.com/questions/63619623
复制相似问题