pytorch-operator on Kubernetes

pytorch-operator

Experimental repo notice: This repository is experimental and currently only serves as a proof of concept for running distributed training with PyTorch on Kubernetes. Current POC is based on TFJob operator

Repository for supporting pytorch. This repo is experimental and is being used to start work related to this proposal.

Prerequisites

Using the PyTorch Operator

Run the following to deploy the operator to the namespace of your current context:

RBAC=true #set false if you do not have an RBAC cluster
helm install pytorch-operator-chart -n pytorch-operator --set rbac.install=${RBAC} --wait --replace

For this POC example we will use a configmap that contains our distributed training script.

kubectl create -f examples/mnist/configmap.yaml

Create a PyTorchJob resource to start training:

kubectl create -f examples/mnist/pytorchjob.yaml

You should now be able to see the job running based on the specified number of replicas.

kubectl get pods -a -l pytorch_job_name=example-job

Training should run for about 10 epochs and takes 5-10 minutes on a cpu cluster. Logs can be inspected while the job runs. (TODO(jose5918) Find a better example for distributed training)

Tail the logs for a pod to see its training progress or final status:

PODNAME=$(kubectl  get pods -a -l pytorch_job_name=example-job,task_index=0 -o name)
kubectl logs -f ${PODNAME}

Example output:

Downloading http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz
Downloading http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz
Downloading http://yann.lecun.com/exdb/mnist/t10k-images-idx3-ubyte.gz
Downloading http://yann.lecun.com/exdb/mnist/t10k-labels-idx1-ubyte.gz
Processing...
Done!
Rank  0 , epoch  0 :  1.2753884393269066
Rank  0 , epoch  1 :  0.5752273188915842
Rank  0 , epoch  2 :  0.4370715184919616
Rank  0 , epoch  3 :  0.37090928852558136
Rank  0 , epoch  4 :  0.3224359404430715
Rank  0 , epoch  5 :  0.29541213348158385
Rank  0 , epoch  6 :  0.27593734307583967
Rank  0 , epoch  7 :  0.25898529327055536
Rank  0 , epoch  8 :  0.24815570648862864
Rank  0 , epoch  9 :  0.22647559368756534

转载于:https://my.oschina.net/u/2306127/blog/1811457

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值