Singularity: Getting things straight with singularity exec

Created on 16 Nov 2018  路  6Comments  路  Source: hpcng/singularity

Version of Singularity:

2.4.1

Expected behavior

run scripts from singularity exec as if they were run from within a singularity shell session. in particular, need a new version of glibc to work such that pytorch can be imported in python. this is so that i can execute pbs jobs on a cluster without opening an interactive job whenever i need singularity.

more specifically, i expect:
singularity exec my.img bash ~/.bashrc && ldd --version to return 2.23 as it does when i call singularity shell my.img; ldd --version.

Actual behavior

Certain things don't work. I have found that adding 'bash ~/.bashrc' as the first command to execute gets my anaconda environment set up, as it naturally is upon a singularity shell session. however, specifically:
singularity exec my.img bash ~/.bashrc && ldd --version returns 2.12, which also happens to be the version of glibc installed on the cluster.

Steps to reproduce behavior

Start with a singularity image with some old version of glibc, install a newer one, and run the line of code above.

Most helpful comment

That won't work ... Try making test.sh

. $HOME/.bashrc
source activate py36
python pcr.py

Then execute it with:
singularity exec my.img test.sh

All 6 comments

This ... is doing exactly what it should be. The && is parsed by the shell before command execution. Everything to the left is taken as one command. If that left side succeeds, then run the part to the right of the &&.

If you're wanting to use exec but run multiple commands, create a shell script that contains the commands you want to run, and exec that script.

Yes sorry I was just about to update.

singularity exec my.img bash ldd --version returns what I want but when I run a bash script calling python, pytorch complains that the glibc version is too old. this is not the case if i run the script after executing singularity shell my.img how can this be?

Hrmmm... how are you executing the script?

bash test.sh | singularity exec my.img bash ~/.bashrc

within test.sh:
source activate py36; python pcr.py

That won't work ... Try making test.sh

. $HOME/.bashrc
source activate py36
python pcr.py

Then execute it with:
singularity exec my.img test.sh

brilliant

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rhattersley picture rhattersley  路  4Comments

Amir-Arsalan picture Amir-Arsalan  路  3Comments

gdolle picture gdolle  路  5Comments

chrisgorgo picture chrisgorgo  路  3Comments

alalazo picture alalazo  路  3Comments