Skip to main content
Version: 1.2.0

Run MPI Jobs

This guide walks through how to setup the MPI Operator and to how to run a MPIJob with the YuniKorn scheduler.

Installing the MPI Operator

You can use the following command to install the mpi operator. If you have problems with installation, please refer to this doc for details.

kubectl create -f https://raw.githubusercontent.com/kubeflow/mpi-operator/master/deploy/v2beta1/mpi-operator.yaml

Run a MPI Job

This example shows to run a pure MPI application.

The program prints some basic information about the workers. Then, it calculates an approximate value for pi.

Here is a Pi YAML example example.

apiVersion: kubeflow.org/v2beta1
kind: MPIJob
metadata:
name: pi
spec:
slotsPerWorker: 1
runPolicy:
cleanPodPolicy: Running
ttlSecondsAfterFinished: 60
sshAuthMountPath: /home/mpiuser/.ssh
mpiReplicaSpecs:
Launcher:
replicas: 1
template:
labels:
applicationId: "mpi_job_pi"
queue: root.mpi
spec:
schedulerName: yunikorn
containers:
- image: mpioperator/mpi-pi
name: mpi-launcher
securityContext:
runAsUser: 1000
command:
- mpirun
args:
- -n
- "2"
- /home/mpiuser/pi
resources:
limits:
cpu: 1
memory: 1Gi
Worker:
replicas: 2
template:
labels:
applicationId: "mpi_job_pi"
queue: root.mpi
spec:
schedulerName: yunikorn
containers:
- image: mpioperator/mpi-pi
name: mpi-worker
securityContext:
runAsUser: 1000
command:
- /usr/sbin/sshd
args:
- -De
- -f
- /home/mpiuser/.sshd_config
resources:
limits:
cpu: 1
memory: 1Gi

Create the MPIJob.

kubectl create -f deployments/examples/mpioperator/Pi/pi.yaml

We added Yunikorn labels to the Pi example to demonstrate using the yunikorn scheduler.