Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using MPI with docker containers

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

It is public on docker-hub at: 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 inside the container) and run it with mpirun.

These are the steps I use and, (if you have Docker installed you can reproduce them too) :

  1. docker run -it orwel84/ubuntu-16-mpi bash
  2. (on container's shell) 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:

Right now all the above four mpi processes run inside a single container.

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

Please help. Thankyou.

like image 916
revolutionary Avatar asked Jan 03 '18 13:01

revolutionary


People also ask

Does Docker support MPI?

Running on a local Docker environment If you are looking for a simple environment to execute your MPI examples. The Docker platform is the best solution suits you.

What is SHM Docker?

The shared memory device, /dev/shm , provides a temporary file storage filesystem using RAM for storing files. It's not mandatory to have /dev/shm , although it's probably desirable since it facilitates inter-process communication (IPC).

When should I use Docker rm?

The flag --rm is used when you need the container to be deleted after the task for it is complete.

What do you use Docker for?

Docker is an open platform for developing, shipping, and running applications. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly. With Docker, you can manage your infrastructure in the same ways you manage your applications.


1 Answers

for multiple containers in a single machine:

1.You can create multiple containers on a single host machine and inspect their ip address (under docker bridge network).

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

2. Now attach to one of the containers and create a host file listing ip-addresses of the containers you have created.

3.Now run the application:

mpirun -np 4 -hostfile hostfile_you_created ./mpi_hello_world
like image 200
psaha4 Avatar answered Sep 21 '22 15:09

psaha4