Skip to content

Latest commit

 

History

History
349 lines (252 loc) · 10.2 KB

podman.rst

File metadata and controls

349 lines (252 loc) · 10.2 KB

Applying Wi4MPI to RedHat container runtime: Podman

Learning objectives

With these hands-on exercises, participants will learn:

  • How to build and execute osu-microbenchmarks into a Podman container using Wi4MPI in preload mode
  • How to build and execute osu-microbenchmarks into a Podman container using Wi4MPI in interface mode
  • In particular, how to switch between different MPI implementations at runtime thanks to Wi4MPI

Once participants complete these exercises, they will be able to build and launch Podman containers using Wi4MPI in their own environments.

Podman

Podman is a software tool that you can use to create, run, and manage containers on a Linux operating system. It does not require a daemon to be running in the background, and is similar to Docker in its capabilities for working with containers. All information in this tutorial can be used with Docker in the same way. Other tools like Singularity or Apptainer should work too but require more adaptations.

In this document, host refers to your own computer (laptop, desktop, cluster...) and container refers to a Podman instance process.

Podman is available through many common package managers such as pacman, apk, yum or apt.

See https://podman.io/getting-started/installation

Using Wi4MPI Preload mode with Podman

During this tutorial, one will use Podman --env and --volume options to link applications inside containers against the MPI implementation available on the host system.

We present the most direct method for using Wi4MPI to this purpose. More advanced methods are available such as using the wi4mpi.cfg configuration file override or containers/hosts system tunings which require more complex examples and explanations.

MPICH containers executed by OpenMPI host

Let's take the following Dockerfile, which contains osu-microbenchmarks compiled with MPICH:

# File name : Dockerfile
# Build with Podman:
#
#   podman build -t omb-mpich .
#
# and execute:
#
#   podman run omb-mpich mpirun -n 2 osu_bw

FROM ubuntu:20.04

# Set the timezone to Paris
ENV TZ=Europe/Paris
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

ARG OSU_VERSION=5.6.2

# Install dependencies
RUN apt-get update && apt-get install -y \
    build-essential \
    git \
    libhwloc-dev \
    make \
    mpich \
    tzdata \
    wget

# Download and extract osu-benchmarks
RUN wget https://mvapich.cse.ohio-state.edu/download/mvapich/osu-micro-benchmarks-${OSU_VERSION}.tar.gz && \
    tar xzf osu-micro-benchmarks-${OSU_VERSION}.tar.gz && \
    rm osu-micro-benchmarks-${OSU_VERSION}.tar.gz

# Build osu-benchmarks
WORKDIR /osu-micro-benchmarks-${OSU_VERSION}
RUN ./configure CC=mpicc CXX=mpicxx && \
    make

# Install osu-benchmarks
RUN make install && \
    ln -s /usr/local/libexec/osu-micro-benchmarks/mpi/*/* /usr/bin/

# Create a non-root user named "poduser"
RUN useradd --create-home --shell /bin/bash poduser

# Set the working directory to the installation directory
WORKDIR /

# Run the container as the "poduser" user
USER poduser

Then, build and execute it with podman:

podman build -t omb-mpich .
podman run omb-mpich mpirun -n 2 osu_bw

The expected output looks something like this:

# OSU MPI Bandwidth Test v5.6.2
# Size      Bandwidth (MB/s)
1                       1.31
2                       3.65
4                       8.07
8                      14.39
[...]

Building containers can take several minutes depending on your computer and network. This container can be executed with the host system OpenMPI and Wi4MPI as follows:

spack unload -a
spack load openmpi
spack load wi4mpi

export OPENMPI_ROOT=/path/to/openmpi

podman run \
    --volume ${SPACK_ROOT}:${SPACK_ROOT} \
    --env WI4MPI_ROOT=${WI4MPI_ROOT} \
    --env PATH=${PATH} \
    --env OPENMPI_ROOT=${OPENMPI_ROOT} \
    omb-mpich mpirun -F mpich -T openmpi -n 2 -- osu_bw

The idea is to propagate the host environment into the container one, then one should see a similar output:

You are using Wi4MPI-3.6.0 with the mode preload From MPICH To OMPI
# OSU MPI Bandwidth Test v5.6.2
# Size      Bandwidth (MB/s)
1                       6.50
2                      12.95
4                      26.23
8                      52.32

OpenMPI containers executed by MPICH host

Let's take the following Dockerfile, which contains osu-microbenchmarks compiled with OpenMPI:

# Build with Podman:
#
#   podman build -t omb-openmpi .
#
# and execute:
#
#   podman run omb-openmpi mpirun -n 2 osu_bw

FROM ubuntu:20.04

# Set the timezone to Paris
ENV TZ=Europe/Paris
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

ARG OSU_VERSION=5.6.2

# Install dependencies
RUN apt-get update && apt-get install -y \
    build-essential \
    git \
    libhwloc-dev \
    make \
    openmpi-bin \
    tzdata \
    wget

# Download and extract osu-benchmarks
RUN wget https://mvapich.cse.ohio-state.edu/download/mvapich/osu-micro-benchmarks-${OSU_VERSION}.tar.gz && \
    tar xzf osu-micro-benchmarks-${OSU_VERSION}.tar.gz && \
    rm osu-micro-benchmarks-${OSU_VERSION}.tar.gz

# Build osu-benchmarks
WORKDIR /osu-micro-benchmarks-${OSU_VERSION}
RUN ./configure CC=mpicc CXX=mpicxx && \
    make

# Install osu-benchmarks
RUN make install && \
    ln -s /usr/local/libexec/osu-micro-benchmarks/mpi/*/* /usr/bin/

# Create a non-root user named "poduser"
RUN useradd --create-home --shell /bin/bash poduser

# Set the working directory to the installation directory
WORKDIR /

# Run the container as the "poduser" user
USER poduser

# Workaround for OpenMPI and Docker compat'
ENV OMPI_MCA_btl_vader_single_copy_mechanism=none

Then, build and execute it with podman:

podman build -t omb-openmpi .
podman run omb-openmpi mpirun -n 2 osu_bw

One should see the following output:

# OSU MPI Bandwidth Test v5.6.2
# Size      Bandwidth (MB/s)
1                       1.70
2                       3.14
4                      10.92
8                      22.67

Building containers could take time depending of your computer and network. This container can be executed using the host's MPICH and Wi4MPI:

spack unload -a
spack load mpich
spack load wi4mpi

export MPICH_ROOT=/path/to/mpich

podman run \
    --volume ${SPACK_ROOT}:${SPACK_ROOT} \
    --env WI4MPI_ROOT=${WI4MPI_ROOT} \
    --env PATH=${PATH} \
    --env MPICH_ROOT=${MPICH_ROOT} \
    omb-openmpi mpirun -F openmpi -T mpich -n 2 -- osu_bw

The goal is to propagate the host environment variables into the container's environment. Doing so should produce an output similar to:

You are using Wi4MPI-3.6.0 with the mode preload From OMPI To MPICH
# OSU MPI Bandwidth Test v5.6.2
# Size      Bandwidth (MB/s)
1                       2.60
2                       5.29
4                      10.60
8                      20.80

Note

The following message can be safely ignored: Symbol 'ompi_mpi_comm_world' has different size in shared object, consider re-linking

Using Wi4MPI Interface mode with Podman

Below is a Dockerfile containing osu-microbenchmarks, compiled with Wi4MPI:

# Build with Podman:
#
#   podman build -t omb-wi4mpi .
#
# and execute:
#
#   podman run omb-wi4mpi mpirun -n 2 -- osu_bw

FROM ubuntu:20.04

ARG OSU_VERSION=5.6.2
...
[Rest of the Dockerfile as you provided]

Note

If you encounter the error undefined reference to dlopen, add LDFLAGS=-Wl,--no-as-needed (see issue #46 for details).

To build and run the container using Podman:

podman build -t omb-wi4mpi .
podman run omb-wi4mpi mpirun -n 2 -- osu_bw

Building containers might take some time depending on your computer's performance and your network speed. But, there no MPI implementation inside the container, so we need to mount the host one and explain to Wi4MPI how to use it.

This container can be executed with the host system MPICH as follow:

spack unload -a
spack load mpich
export MPICH_ROOT=/path/to/mpich

podman run \
    --volume ${SPACK_ROOT}:${SPACK_ROOT} \
    --env PATH=${PATH} \
    --env MPICH_ROOT=${MPICH_ROOT} \
    omb-wi4mpi mpirun -T mpich -n 2 -- osu_bw

The idea is to propagate the host environment into the container one, then one should see a similar output:

You are using Wi4MPI-3.6.4 with the mode interface From Interface To MPICH
# OSU MPI Bandwidth Test v5.6.2
# Size      Bandwidth (MB/s)
1                       2.49
2                       5.03
4                      10.23
8                      20.41

Note

  1. The host system does not require Wi4MPI for this translation; the container's Wi4MPI is utilized.
  2. The warning message Symbol 'ompi_mpi_comm_world' has different size in shared object, consider re-linking can be disregarded.

Here is the same execution with OpenMPI host:

spack unload -a
spack load openmpi
export OPENMPI_ROOT=/path/to/openmpi

podman run \
    --volume ${SPACK_ROOT}:${SPACK_ROOT} \
    --env PATH=${PATH} \
    --env OPENMPI_ROOT=${OPENMPI_ROOT} \
    omb-wi4mpi mpirun -T openmpi -n 2 -- osu_bw

With the above configuration, expect an output similar to:

You are using Wi4MPI-3.6.4 with the mode interface From Interface To OMPI
# OSU MPI Bandwidth Test v5.6.2
# Size      Bandwidth (MB/s)
1                       3.66
2                       7.63
4                      15.32
8                      30.95