一. 為什么希望使用容器來作為深度學(xué)習(xí)系統(tǒng)的調(diào)度單元
容器拉取/啟動快速别厘。隔離資源效果好趣兄。抽象來看阅悍,可以將容器的image作為job的一部分分發(fā)調(diào)度執(zhí)行。但是容器化后會引入gpu脱拼,網(wǎng)絡(luò)等性能的代價(jià)。nvidia gpu 對docker提供了支持坷备,nvidia-docker代替docker執(zhí)行create和run操作熄浓。cuda和cudnn鏡像在這里
二. kubernetes(k8s)
kubernetes作為google開源的容器編排工具,發(fā)展十分迅速省撑。最近release的版本是v1.4.1赌蔑,已經(jīng)十分穩(wěn)定。
說明
- 每個node下面
docker engine:負(fù)責(zé)下載運(yùn)行鏡像
kubelet:管理pod已經(jīng)里面的container
kube-proxy:服務(wù)發(fā)現(xiàn)的proxy竟秫,代理網(wǎng)絡(luò)流量 - kubernetes控制中心
etcd:持久化支持觀察者模式的配置中心娃惯,etcd高可用十分重要
API Server:操作的接口
Scheduler:調(diào)度pods(container的小集合)到指定node運(yùn)行,這個實(shí)際可以替換使用Mesos
Kubernetes Controller Manager Server:管理如保持副本個數(shù)等功能
Kubernetes與mesos的區(qū)別 @stackoverflow
- Kubernetes is a great place to start if you are new to the clustering world; it is the quickest, easiest and lightest way to kick the tires and start experimenting with cluster oriented development. It offers a very high level of portability since it is being supported by a lot of different providers (Microsoft, IBM, Red Hat, CoreOs, MesoSphere, VMWare, etc).
- If you have existing workloads (Hadoop, Spark, Kafka, etc), Mesos gives you a framework that let's you interleave those workloads with each other, and mix in a some of the new stuff including Kubernetes apps.
- Mesos gives you an escape valve if you need capabilities that are not yet implemented by the community in the Kubernetes framework.
Kubernetes可以代替Marathon肥败,在Mesos之上搭建cluster的工具
三. openai的分布式深度學(xué)習(xí)系統(tǒng)
openai科學(xué)家們的訓(xùn)練日常需求
- 小數(shù)據(jù)量趾浅,小模型的實(shí)驗(yàn),快速嘗試馒稍,一般需要幾小時(shí)完成一次實(shí)驗(yàn)
- 大數(shù)據(jù)量皿哨,大模型。一般需要幾天完成一次實(shí)驗(yàn)
- 日志對于分析定位十分重要纽谒,應(yīng)該被持久化和更好的展示
一般使用的工具箱
分布式深度學(xué)習(xí)關(guān)鍵技術(shù)
- 使用物理gpu機(jī)器和aws 提供的cpu機(jī)器搭建混合集群
- 使用kubernetes編排容器
- 自定義組件來支持不同job動態(tài)擴(kuò)容/縮容的需求,kubernetes-ec2-autoscaler
- 使用 Terraform 構(gòu)建每個機(jī)器的基礎(chǔ)環(huán)境鼓黔,使用Chef統(tǒng)一服務(wù)器配置椎例。
四. tensorflow的分布式架構(gòu)
tensorflow從V0.8開始支持分布式訓(xùn)練,目前穩(wěn)定的版本是r0.11请祖。詳細(xì)的分布式訓(xùn)練的方案在這里订歪。
幾個主要的概念
-
Cluster
Cluser由一組Server組成,Server的功能可以是Worker也可以是PS肆捕。Worker中被client用session連接的作為master刷晋,提供協(xié)調(diào),記錄慎陵,checkpoint的功能 -
Job
Job包含多個Task眼虱,Job的典型角色是Worker或者PS -
Master service
實(shí)現(xiàn)接口tensorflow::Session功能,協(xié)調(diào)worker工作席纽。每個server都有實(shí)現(xiàn) -
TensorFlow server
每個server都實(shí)現(xiàn)了"master service" 和 "worker service"
個人理解
- 提供的分布式功能還不是很完善
提交腳本需要多臺機(jī)器上執(zhí)行,不方便 - 粒度為整個機(jī)器
一個task在一臺機(jī)器上可能占不滿捏悬,也可能與其他job中的task相互影響,比如:都使用gpu0
update--
將開源資源調(diào)度工具與tensorflow分布式訓(xùn)練結(jié)合起來的github润梯, ecosystem
docker - Docker configuration for running TensorFlow on cluster managers.
kubernetes - Templates for running distributed TensorFlow on Kubernetes.
marathon - Templates for running distributed TensorFlow using Marathon, deployed on top of Mesos.
hadoop - TFRecord file InputFormat/OutputFormat for Hadoop MapReduce and Spark.