我嘗試使用我的定義文件擴展pytorch docker 映像nnunet.def:Bootstrap: dockerFrom: 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 foundFATAL:? ?failed to execute %post proc: exit status 127FATAL:? ?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 freezeasn1crypto==1.2.0backcall==0.1.0...為什么我不能在%post定義文件的部分中使用 pip?
1 回答

呼啦一陣風
TA貢獻1802條經驗 獲得超6個贊
$PATH
簡短的回答: in的值%post
與您在 shell 中運行時不同,因此它不知道去哪里查找。
如果您查看 pipwhich pip
在 docker 或奇異點映像中的位置 ( ),您會發現它位于/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
它應該可以解決這個問題。
添加回答
舉報
0/150
提交
取消