• Stars
    star
    392
  • Rank 109,735 (Top 3 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created over 6 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Kubernetes Operator for MPI-based applications (distributed training, HPC, etc.)

MPI Operator

Build Status Docker Pulls

The MPI Operator makes it easy to run allreduce-style distributed training on Kubernetes. Please check out this blog post for an introduction to MPI Operator and its industry adoption.

Installation

You can deploy the operator with default settings by running the following commands:

  • Latest Development Version
kubectl apply -f https://raw.githubusercontent.com/kubeflow/mpi-operator/master/deploy/v2beta1/mpi-operator.yaml
  • Release Version
kubectl apply -f https://raw.githubusercontent.com/kubeflow/mpi-operator/v0.4.0/deploy/v2beta1/mpi-operator.yaml

Alternatively, follow the getting started guide to deploy Kubeflow.

An alpha version of MPI support was introduced with Kubeflow 0.2.0. You must be using a version of Kubeflow newer than 0.2.0.

You can check whether the MPI Job custom resource is installed via:

kubectl get crd

The output should include mpijobs.kubeflow.org like the following:

NAME                                       AGE
...
mpijobs.kubeflow.org                       4d
...

If it is not included, you can add it as follows using kustomize:

git clone https://github.com/kubeflow/mpi-operator
cd mpi-operator
kustomize build manifests/overlays/kubeflow | kubectl apply -f -

Note that since Kubernetes v1.14, kustomize became a subcommand in kubectl so you can also run the following command instead:

Since Kubernetes v1.21, you can use:

kubectl apply -k manifests/overlays/kubeflow
kubectl kustomize base | kubectl apply -f -

Creating an MPI Job

You can create an MPI job by defining an MPIJob config file. See TensorFlow benchmark example config file for launching a multi-node TensorFlow benchmark training job. You may change the config file based on your requirements.

cat examples/v2beta1/tensorflow-benchmarks/tensorflow-benchmarks.yaml

Deploy the MPIJob resource to start training:

kubectl apply -f examples/v2beta1/tensorflow-benchmarks/tensorflow-benchmarks.yaml

Monitoring an MPI Job

Once the MPIJob resource is created, you should now be able to see the created pods matching the specified number of GPUs. You can also monitor the job status from the status section. Here is sample output when the job is successfully completed.

kubectl get -o yaml mpijobs tensorflow-benchmarks
apiVersion: kubeflow.org/v2beta1
kind: MPIJob
metadata:
  creationTimestamp: "2019-07-09T22:15:51Z"
  generation: 1
  name: tensorflow-benchmarks
  namespace: default
  resourceVersion: "5645868"
  selfLink: /apis/kubeflow.org/v1alpha2/namespaces/default/mpijobs/tensorflow-benchmarks
  uid: 1c5b470f-a297-11e9-964d-88d7f67c6e6d
spec:
  runPolicy:
    cleanPodPolicy: Running
  mpiReplicaSpecs:
    Launcher:
      replicas: 1
      template:
        spec:
          containers:
          - command:
            - mpirun
            - --allow-run-as-root
            - -np
            - "2"
            - -bind-to
            - none
            - -map-by
            - slot
            - -x
            - NCCL_DEBUG=INFO
            - -x
            - LD_LIBRARY_PATH
            - -x
            - PATH
            - -mca
            - pml
            - ob1
            - -mca
            - btl
            - ^openib
            - python
            - scripts/tf_cnn_benchmarks/tf_cnn_benchmarks.py
            - --model=resnet101
            - --batch_size=64
            - --variable_update=horovod
            image: mpioperator/tensorflow-benchmarks:latest
            name: tensorflow-benchmarks
    Worker:
      replicas: 1
      template:
        spec:
          containers:
          - image: mpioperator/tensorflow-benchmarks:latest
            name: tensorflow-benchmarks
            resources:
              limits:
                nvidia.com/gpu: 2
  slotsPerWorker: 2
status:
  completionTime: "2019-07-09T22:17:06Z"
  conditions:
  - lastTransitionTime: "2019-07-09T22:15:51Z"
    lastUpdateTime: "2019-07-09T22:15:51Z"
    message: MPIJob default/tensorflow-benchmarks is created.
    reason: MPIJobCreated
    status: "True"
    type: Created
  - lastTransitionTime: "2019-07-09T22:15:54Z"
    lastUpdateTime: "2019-07-09T22:15:54Z"
    message: MPIJob default/tensorflow-benchmarks is running.
    reason: MPIJobRunning
    status: "False"
    type: Running
  - lastTransitionTime: "2019-07-09T22:17:06Z"
    lastUpdateTime: "2019-07-09T22:17:06Z"
    message: MPIJob default/tensorflow-benchmarks successfully completed.
    reason: MPIJobSucceeded
    status: "True"
    type: Succeeded
  replicaStatuses:
    Launcher:
      succeeded: 1
    Worker: {}
  startTime: "2019-07-09T22:15:51Z"

Training should run for 100 steps and takes a few minutes on a GPU cluster. You can inspect the logs to see the training progress. When the job starts, access the logs from the launcher pod:

PODNAME=$(kubectl get pods -l training.kubeflow.org/job-name=tensorflow-benchmarks,training.kubeflow.org/job-role=launcher -o name)
kubectl logs -f ${PODNAME}
TensorFlow:  1.14
Model:       resnet101
Dataset:     imagenet (synthetic)
Mode:        training
SingleSess:  False
Batch size:  128 global
             64 per device
Num batches: 100
Num epochs:  0.01
Devices:     ['horovod/gpu:0', 'horovod/gpu:1']
NUMA bind:   False
Data format: NCHW
Optimizer:   sgd
Variables:   horovod

...

40	images/sec: 154.4 +/- 0.7 (jitter = 4.0)	8.280
40	images/sec: 154.4 +/- 0.7 (jitter = 4.1)	8.482
50	images/sec: 154.8 +/- 0.6 (jitter = 4.0)	8.397
50	images/sec: 154.8 +/- 0.6 (jitter = 4.2)	8.450
60	images/sec: 154.5 +/- 0.5 (jitter = 4.1)	8.321
60	images/sec: 154.5 +/- 0.5 (jitter = 4.4)	8.349
70	images/sec: 154.5 +/- 0.5 (jitter = 4.0)	8.433
70	images/sec: 154.5 +/- 0.5 (jitter = 4.4)	8.430
80	images/sec: 154.8 +/- 0.4 (jitter = 3.6)	8.199
80	images/sec: 154.8 +/- 0.4 (jitter = 3.8)	8.404
90	images/sec: 154.6 +/- 0.4 (jitter = 3.7)	8.418
90	images/sec: 154.6 +/- 0.4 (jitter = 3.6)	8.459
100	images/sec: 154.2 +/- 0.4 (jitter = 4.0)	8.372
100	images/sec: 154.2 +/- 0.4 (jitter = 4.0)	8.542
----------------------------------------------------------------
total images/sec: 308.27

For a sample that uses Intel MPI, see:

cat examples/pi/pi-intel.yaml

For a sample that uses MPICH, see:

cat examples/pi/pi-mpich.yaml

Exposed Metrics

Metric name Metric type Description Labels
mpi_operator_jobs_created_total Counter Counts number of MPI jobs created
mpi_operator_jobs_successful_total Counter Counts number of MPI jobs successful
mpi_operator_jobs_failed_total Counter Counts number of MPI jobs failed
mpi_operator_job_info Gauge Information about MPIJob launcher=<launcher-pod-name>
namespace=<job-namespace>

Join Metrics

With kube-state-metrics, one can join metrics by labels. For example kube_pod_info * on(pod,namespace) group_left label_replace(mpi_operator_job_infos, "pod", "$0", "launcher", ".*")

Docker Images

We push Docker images of mpioperator on Dockerhub for every release. You can use the following Dockerfile to build the image yourself:

Alternative, you can build the image using make:

make RELEASE_VERSION=dev IMAGE_NAME=registry.example.com/mpi-operator images

This will produce an image with the tag registry.example.com/mpi-operator:dev.

Contributing

Learn more in CONTRIBUTING.

More Repositories

1

kubeflow

Machine Learning Toolkit for Kubernetes
TypeScript
13,574
star
2

pipelines

Machine Learning Pipelines for Kubeflow
Python
3,593
star
3

spark-operator

Kubernetes operator for managing the lifecycle of Apache Spark applications on Kubernetes.
Go
2,765
star
4

training-operator

Distributed ML Training and Fine-Tuning on Kubernetes
Go
1,561
star
5

katib

Repository for hyperparameter tuning
Go
1,415
star
6

examples

A repository to host extended examples and tutorials
Jsonnet
1,400
star
7

manifests

A repository for Kustomize manifests
YAML
735
star
8

arena

A CLI for Kubeflow.
Go
730
star
9

fairing

Python SDK for building, training, and deploying ML models
Jsonnet
335
star
10

pytorch-operator

PyTorch on Kubernetes
Jsonnet
301
star
11

kfctl

kfctl is a CLI for deploying and managing Kubeflow
Go
177
star
12

example-seldon

Example for end-to-end machine learning on Kubernetes using Kubeflow and Seldon Core
Jupyter Notebook
172
star
13

kfp-tekton

Kubeflow Pipelines on Tekton
TypeScript
171
star
14

community

Information about the Kubeflow community including proposals and governance information.
Jsonnet
156
star
15

website

Kubeflow Website
HTML
148
star
16

metadata

Repository for assets related to Metadata.
TypeScript
120
star
17

xgboost-operator

Incubating project for xgboost operator
Python
76
star
18

kubebench

Repository for benchmarking
Jsonnet
75
star
19

testing

Test infrastructure and tooling for Kubeflow.
Python
63
star
20

code-intelligence

ML-Powered Developer Tools, using Kubeflow
Jupyter Notebook
56
star
21

mxnet-operator

A Kubernetes operator for mxnet jobs
Go
53
star
22

common

Common APIs and libraries shared by other Kubeflow operator repositories.
Go
51
star
23

fate-operator

Fate operator
Go
50
star
24

model-registry

Go
32
star
25

batch-predict

Repository for batch predict
Python
17
star
26

chainer-operator

Repository for chainer operator
Jsonnet
17
star
27

blog

Kubeflow blog based on fastpages
Jupyter Notebook
16
star
28

caffe2-operator

Experimental repository for a caffe2 operator
Go
16
star
29

internal-acls

Repository used to main group ACLs used by Kubeflow developers
Go
14
star
30

crd-validation

Validation Generation for Kubeflow CRD on Kubernetes
Go
11
star
31

kfserving-lts

Jsonnet
10
star
32

frontend

Repository for kubeflow frontend
JavaScript
8
star
33

kfp-tekton-backend

Experimental project plugging Tekton yaml behind KFP API and UI engine
TypeScript
8
star
34

marketing-materials

4
star
35

community-infra

Declarative configurations for KF community infrastructure
Go
3
star
36

fastpages

fastpages is a platform for blogging
Jupyter Notebook
3
star
37

.allstar

2
star
38

reporting

Repository for collecting and analyzing metrics about Kubeflow usage.
Jsonnet
2
star
39

.github

Org wide templates
2
star
40

dashboard

1
star