• This repository has been archived on 19/Sep/2022
  • Stars
    star
    301
  • Rank 137,672 (Top 3 %)
  • Language Jsonnet
  • License
    Apache License 2.0
  • Created over 6 years ago
  • Updated almost 3 years ago

Reviews

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

Repository Details

PyTorch on Kubernetes

Kubernetes Custom Resource and Operator for PyTorch jobs

⚠️ kubeflow/pytorch-operator is not maintained

This operator has been merged into Kubeflow Training Operator. This repository is not maintained and has been archived.

Build Status Go Report Card

Overview

This repository contains the specification and implementation of PyTorchJob custom resource definition. Using this custom resource, users can create and manage PyTorch jobs like other built-in resources in Kubernetes. See CRD definition

Prerequisites

Installing PyTorch Operator

Please refer to the installation instructions in the Kubeflow user guide. This installs pytorchjob CRD and pytorch-operator controller to manage the lifecycle of PyTorch jobs.

Creating a PyTorch Job

You can create PyTorch Job by defining a PyTorchJob config file. See the manifests for the distributed MNIST example. You may change the config file based on your requirements.

cat examples/mnist/v1/pytorch_job_mnist_gloo.yaml

Deploy the PyTorchJob resource to start training:

kubectl create -f examples/mnist/v1/pytorch_job_mnist_gloo.yaml

You should now be able to see the created pods matching the specified number of replicas.

kubectl get pods -l pytorch-job-name=pytorch-dist-mnist-gloo

Training should run for about 10 epochs and takes 5-10 minutes on a cpu cluster. Logs can be inspected to see its training progress.

PODNAME=$(kubectl get pods -l pytorch-job-name=pytorch-dist-mnist-gloo,pytorch-replica-type=master -o name)
kubectl logs -f ${PODNAME}

Monitoring a PyTorch Job

kubectl get -o yaml pytorchjobs pytorch-dist-mnist-gloo

See status section to monitor the job status. Here is sample output when the job is successfully completed.

apiVersion: v1
items:
- apiVersion: kubeflow.org/v1
  kind: PyTorchJob
  metadata:
    creationTimestamp: 2019-01-11T00:51:48Z
    generation: 1
    name: pytorch-dist-mnist-gloo
    namespace: default
    resourceVersion: "2146573"
    selfLink: /apis/kubeflow.org/v1/namespaces/kubeflow/pytorchjobs/pytorch-dist-mnist-gloo
    uid: 13ad0e7f-153b-11e9-b5c1-42010a80001e
  spec:
    pytorchReplicaSpecs:
      Master:
        replicas: 1
        restartPolicy: OnFailure
        template:
          spec:
            containers:
            - args:
              - --backend
              - gloo
              image: gcr.io/kubeflow-ci/pytorch-dist-mnist-test:v1.0
              name: pytorch
              resources:
                limits:
                  nvidia.com/gpu: "1"
      Worker:
        replicas: 1
        restartPolicy: OnFailure
        template:
          spec:
            containers:
            - args:
              - --backend
              - gloo
              image: gcr.io/kubeflow-ci/pytorch-dist-mnist-test:v1.0
              name: pytorch
              resources:
                limits:
                  nvidia.com/gpu: "1"
  status:
    completionTime: 2019-01-11T01:03:15Z
    conditions:
    - lastTransitionTime: 2019-01-11T00:51:48Z
      lastUpdateTime: 2019-01-11T00:51:48Z
      message: PyTorchJob pytorch-dist-mnist-gloo is created.
      reason: PyTorchJobCreated
      status: "True"
      type: Created
    - lastTransitionTime: 2019-01-11T00:57:22Z
      lastUpdateTime: 2019-01-11T00:57:22Z
      message: PyTorchJob pytorch-dist-mnist-gloo is running.
      reason: PyTorchJobRunning
      status: "False"
      type: Running
    - lastTransitionTime: 2019-01-11T01:03:15Z
      lastUpdateTime: 2019-01-11T01:03:15Z
      message: PyTorchJob pytorch-dist-mnist-gloo is successfully completed.
      reason: PyTorchJobSucceeded
      status: "True"
      type: Succeeded
    replicaStatuses:
      Master:
        succeeded: 1
      Worker:
        succeeded: 1
    startTime: 2019-01-11T00:57:22Z

Contributing

Please refer to the developer_guide.

More Repositories

1

kubeflow

Machine Learning Toolkit for Kubernetes
TypeScript
13,574
star
2

pipelines

Machine Learning Pipelines for Kubeflow
Python
3,550
star
3

spark-operator

Kubernetes operator for managing the lifecycle of Apache Spark applications on Kubernetes.
Go
2,724
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,386
star
7

manifests

A repository for Kustomize manifests
YAML
735
star
8

arena

A CLI for Kubeflow.
Go
730
star
9

mpi-operator

Kubernetes Operator for MPI-based applications (distributed training, HPC, etc.)
Go
392
star
10

fairing

Python SDK for building, training, and deploying ML models
Jsonnet
335
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
153
star
15

website

Kubeflow's public website
HTML
146
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

triage-issues

For triaging issues in kubeflow
1
star
41

dashboard

1
star