Red Hat Training

A Red Hat training course is available for RHEL 8

第23章 HPC 環境での Podman の使用

Podman を Open MPI (Message Passing Interface) と共に使用して、HPC (High Performance Computing) 環境でコンテナーを実行できます。

23.1. Podman と MPI の使用

この例は、Open MPI から取得した ring.c プログラムを基にしています。この例では、全プロセスで値はリングのように渡されます。メッセージがランク 0 を渡すと必ず、値は 1 つ下がります。各プロセスが 0 メッセージを受信すると、次のプロセスに渡して終了します。0 を最初に渡すと、すべてのプロセスが 0 メッセージを取得し、通常通りに終了できます。

前提条件

  • container-tools モジュールがインストールされている。

手順

  1. Open MPI をインストールします。

    # yum install openmpi
  2. 環境モジュールをアクティベートするには、以下を入力します。

    $ . /etc/profile.d/modules.sh
  3. mpi/openmpi-x86_64 モジュールを読み込みます。

    $ module load mpi/openmpi-x86_64

    必要に応じて、mpi/openmpi-x86_64 モジュールを自動的に読み込むには、以下の行を .bashrc ファイルに追加します。

    $ echo "module load mpi/openmpi-x86_64" >> .bashrc
  4. mpirunpodman を統合するには、以下の定義でコンテナーを作成します。

    $ cat Containerfile
    FROM registry.access.redhat.com/ubi8/ubi
    
    RUN yum -y install openmpi-devel wget && \
        yum clean all
    
    RUN wget https://raw.githubusercontent.com/open-mpi/ompi/master/test/simple/ring.c && \
        /usr/lib64/openmpi/bin/mpicc ring.c -o /home/ring && \
        rm -f ring.c
  5. コンテナーをビルドします。

    $ podman build --tag=mpi-ring .
  6. コンテナーを起動します。このコマンドは、CPU が 4 つあるシステムではコンテナーを 4 つ起動します。

    $ mpirun \
       --mca orte_tmpdir_base /tmp/podman-mpirun \
       podman run --env-host \
        -v /tmp/podman-mpirun:/tmp/podman-mpirun \
        --userns=keep-id \
        --net=host --pid=host --ipc=host \
        mpi-ring /home/ring
    Rank 2 has cleared MPI_Init
    Rank 2 has completed ring
    Rank 2 has completed MPI_Barrier
    Rank 3 has cleared MPI_Init
    Rank 3 has completed ring
    Rank 3 has completed MPI_Barrier
    Rank 1 has cleared MPI_Init
    Rank 1 has completed ring
    Rank 1 has completed MPI_Barrier
    Rank 0 has cleared MPI_Init
    Rank 0 has completed ring
    Rank 0 has completed MPI_Barrier

    これにより、mpirun は 4 つの Podman コンテナーを開始し、コンテナーごとに ring バイナリーのインスタンスを 1 台実行します。4 つプロセスはすべて、MPI 経由で相互に通信しています。