So, I guess this is done in a really simple way, but I do not have experience with it, so I do not understand what is the issue. Let's say I have a conda environment example_env
and a Singularity image example.simg
.
I can run the image:
singularity run --nv /mnt/appl/singularity_images/pytorch-19.03-py3.simg
Once I am in the Singularity container, I can write conda activate example_env
, and it works for me without any problem.
Now, I want to switch from the interactive section to a script. So, instead of using singularity run
and entering the interactive shell, I have tried singularity exec
: singularity exec example.simg bash scripts/train.sh
, where train.sh
contains only one (just for now, of course) command: conda activate example_env
.
However, now it does not work, and gives me the following error: CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'. To initialize your shell, run $ conda init <SHELL_NAME>
If I try to follow the error message, and add the conda init
command, it does not help.
What is wrong, and how can I run conda activate
with singularity exec
?