2.4.1
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.
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.
Start with a singularity image with some old version of glibc, install a newer one, and run the line of code above.
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
Most helpful comment
That won't work ... Try making test.sh
Then execute it with:
singularity exec my.img test.sh