1
votes

I'm using OpenMPI and mpirun, and my MPI processes are divided among multiple Docker containers. Each Docker container is running its own process that has an environment variable, say, FOO, where $FOO (i.e. its value) differs depending on the container. The process running in the master node is the one that calls the mpirun. Is there a way for me to get each worker node to have FOO set in its MPI process in the mpirun command?

My question is different from this one in that the values of the environment variables may differ from container to container. Using -x in the mpirun command exports the master node's value for the environment variable, so that doesn't work for what I'm trying to do.

edit: revised to clarify based on the comment

1
an environment variable belongs to a process and not a container. you first need to figure out how (so to speak) "the variable is set in the container environment" and find how to have it set in a MPI task (how was it started?) running on that container.Gilles Gouaillardet
the second part of that "how to have it set in a MPI task (how was it started?) running on that container" is what I'm looking for with this question. (I've edited the question to clarify the first part.)lauren
Did you already figure out how "the variable is set in the container environment"? meanwhile you can try to unset FOO before invoking mpirun, that might be enough for you (mpirun will no more "export" the FOO environment variable to the MPI tasks, and hence might leave a chance for them to get the value that was already set I do not know how.Gilles Gouaillardet

1 Answers

0
votes

Posting in case this ends up being helpful for anyone else -

I ended up solving this by writing the environment variables to /etc/environment before starting the MPI process. My Docker images use Ubuntu as a base, and /etc/environment is honored even in a non-interactive, non-login shell (which is what MPI uses).