MindSpore Operator 是MindSpore在Kubernetes上进行分布式训练的插件。CRD(Custom Resource Definition)中定义了Scheduler、PS、Worker三种角色,用户只需配置yaml文件,即可轻松实现分布式训练。
安装方法可以有以下几种
kubectl apply -f deploy/v1/ms-operator.yaml
安装后:
使用kubectl get pods --all-namespaces
,即可看到namespace为ms-operator-system的部署任务。
使用kubectl describe pod ms-operator-controller-manager-xxx-xxx -n ms-operator-system
,可查看pod的详细信息。
make deploy IMG=swr.cn-south-1.myhuaweicloud.com/mindspore/ms-operator:latest
make run
当前ms-operator支持普通单Worker训练、PS模式的单Worker训练以及自动并行(例如数据并行、模型并行等)的Scheduler、Worker启动。
在config/samples/
中有运行样例。
以数据并行的Scheduler、Worker启动为例,其中数据集和网络脚本需提前准备:
kubectl apply -f config/samples/ms_wide_deep_dataparallel.yaml
使用kubectl get all -o wide
即可看到集群中启动的Scheduler和Worker,以及Scheduler对应的Service。
pkg/apis/v1/msjob_types.go
中为MSJob的CRD定义。
pkg/controllers/v1/msjob_controller.go
中为MSJob controller的核心逻辑。
make docker-build IMG=swr.cn-south-1.myhuaweicloud.com/mindspore/ms-operator:latest
docker push swr.cn-south-1.myhuaweicloud.com/mindspore/ms-operator:latest