Using MPI with Docker Containers

I created an image docker based on Ubuntu 16.04 and with all the dependencies needed to run MPI.

Publicly on the docker hub: https://hub.docker.com/r/orwel84/ubuntu-16-mpi/

I use this image to create an MPI container. I can also compile a simple mpi-hello-world.c (which comes in the container) and run it with mpirun.

These are the steps I'm using, and (if you have Docker installed, you can reproduce them):

  • docker run -it orwel84/ubuntu-16-mpi bash
  • (on container) mpirun -np 4 --allow-run-as-root ./mpi_hello_world

You will see Output:

 Hello world from processor 6f9b11cef939, rank 0 out of 4 processors Hello world from processor 6f9b11cef939, rank 1 out of 4 processors Hello world from processor 6f9b11cef939, rank 2 out of 4 processors Hello world from processor 6f9b11cef939, rank 3 out of 4 processors 

Question:

Currently, all of the above four mpi processes are running inside the same container.

How to use mpirun to run in multiple containers on the same host? And also how can I use Docker swarm to run a swarm on multiple nodes?

Please, help. Thankyou.

+5
source share
1 answer

for several containers in one machine:

1.You can create several containers on one host computer and check their IP address (in the docker bridge network).

 docker inspect -f "{{ .NetworkSettings.IPAddress }}" containerName 

2. Now join one of the containers and create a host file that lists the IP addresses of the containers you created.

3. Now run the application:

 mpirun -np 4 -hostfile hostfile_you_created ./mpi_hello_world 
0
source

Source: https://habr.com/ru/post/1274469/


All Articles