bru*_*ran 4 conda singularity-container
我正在使用 Singularity 容器来运行来自 Nextflow 工作流管理系统的命令。我在 Singularity 中有一个 conda 环境,当我进入容器时可以激活它
singularity pull shub://brucemoran/Singularity:pcgr.centos7
singularity shell brucemoran-Singularity-pcgr.centos7.img
#<inside container>
source activate pcgr
Run Code Online (Sandbox Code Playgroud)
当 Nextflow 执行时,我已经定义了source activate pcgr我认为应该激活 conda env 的位置。但我收到unbound variable HOST警告。我认为这与未激活和随后使用变量有关,如果环境已激活,则应定义这些变量(?)。
我希望容器在执行时激活 env (pcgr)。我尝试过
%run
source activate pcgr
Run Code Online (Sandbox Code Playgroud)
和
%post
source activate pcgr
Run Code Online (Sandbox Code Playgroud)
但这对我不起作用
singularity exec pcgr.img which pcgr.py
which: no pcgr.py in ...
Run Code Online (Sandbox Code Playgroud)
我看不出这是如何完成的,但假设这很容易,而且我严重忽略了一些事情!
帮助表示赞赏。
奇点中的 shell 运行在特殊的环境中,因此标准 conda 的修改不起作用.bashrc。相反,您需要修改$SINGULARITY_ENVIRONMENT变量。Singularity 定义文件中的这些内容应该有效:
# set to whatever your conda path is, I usually install to /opt
echo ". /opt/conda/etc/profile.d/conda.sh" >> $SINGULARITY_ENVIRONMENT
echo "conda activate pcgr" >> $SINGULARITY_ENVIRONMENT
Run Code Online (Sandbox Code Playgroud)
这样conda环境就会自动激活。如果您希望在步骤中手动激活它,则可以省略第二行并在%run步骤中执行此操作。
编辑:更改为 using.而不是为了source与 with 兼容/bin/sh,在下面的评论中提到
| 归档时间: |
|
| 查看次数: |
3706 次 |
| 最近记录: |