【问题标题】:How to add default script to run inside a singularity container?如何添加默认脚本以在奇点容器内运行?
【发布时间】:2020-02-28 16:46:43
【问题描述】:

我正在尝试基于预先构建的 anaconda2 映像构建一个奇点容器,例如:

singularity build --sandbox hmmhc.sif library://shahzebmsiddiqui/easybuild/anaconda2:5.2.0
singularity exec hmmhc.sif python --version
Python 2.7.15 :: Anaconda, Inc.

基于此,我使用singularity shell 安装了hmmhc 程序。我想知道如何在内部激活程序,例如在图像内部运行以下行:

source ~/anaconda2/etc/profile.d/conda.sh
conda activate hmmhc

这样我就可以执行它:

singularity exec hmmhc.sif hmmhc-predict --help

【问题讨论】:

    标签: docker anaconda singularity-container


    【解决方案1】:

    如果您使用Singularity definition file,则只能添加/编辑默认运行选项。我建议使用此选项以提高可重复性,但在这种情况下并非严格要求。

    假设您按照 github 上的安装说明进行操作,您为该软件包创建了一个新的 conda 环境。问题是因为 conda 环境不是默认环境。相反,您可以将软件包安装到基本/默认 conda 环境中,然后singularity exec 可以使用它。

    # in singularity shell
    conda config --prepend channels bioconda
    conda install ghmm=0.9 'icu=58.*'
    pip install git+https://github.com/artyomovlab/hmmhc#egg=hmmhc
    
    # check the image works as expected
    singularity exec hmmhc.sif/ hmmhc-predict --help
    

    【讨论】:

    • 谢谢@tsnowlan。我将 hmmhc.sif scp 编辑到我的本地服务器并运行相同的命令singularity exec hmmhc.sif/ hmmhc-predict --help,但收到了/.singularity.d/env/90-environment.sh: line 13: module: command not found 的消息。你有什么建议可以解决吗?
    • 猜测它正在尝试在内部使用 HPC 集群中常见的 module 系统,并且它没有安装在映像中。您可以查看该文件的内容,以了解它的具体用途:cat hmmhc.sif/.singularity.d/env/90-environment.sh
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-04-21
    • 2015-10-13
    • 1970-01-01
    • 2021-12-20
    • 2015-08-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多