This repository was archived by the owner on Nov 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathtensorflowdistributedtrainingwithdefaultscheduledgpu.yaml
More file actions
180 lines (179 loc) · 7.65 KB
/
tensorflowdistributedtrainingwithdefaultscheduledgpu.yaml
File metadata and controls
180 lines (179 loc) · 7.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# For the full spec setting and usage, see ./pkg/apis/frameworkcontroller/v1/types.go
# For the full frameworkbarrier usage, see ./pkg/barrier/barrier.go
############################### Prerequisite ###################################
# See "[PREREQUISITE]" in this file.
################################################################################
apiVersion: frameworkcontroller.microsoft.com/v1
kind: Framework
metadata:
name: tensorflowdistributedtrainingwithdefaultscheduledgpu
spec:
executionType: Start
retryPolicy:
fancyRetryPolicy: true
maxRetryCount: 2
taskRoles:
- name: ps
taskNumber: 2
frameworkAttemptCompletionPolicy:
minFailedTaskCount: 1
minSucceededTaskCount: -1
task:
retryPolicy:
fancyRetryPolicy: false
maxRetryCount: 0
pod:
spec:
restartPolicy: Never
# [PREREQUISITE]
# User needs to setup the k8s cluster networking model and aware the
# potential network overhead, if he want to disable the hostNetwork to
# avoid the coordination of the containerPort usage.
# And for this example, if the hostNetwork is disabled, it only needs
# at least 1 node, otherwise, it needs at least 3 nodes since all the
# 3 workers are specified with the same containerPort.
# See https://kubernetes.io/docs/concepts/cluster-administration/networking
hostNetwork: false
containers:
- name: tensorflow
# Using official image to demonstrate this example.
# The image contains and only contains tensorflow official code.
image: frameworkcontroller/tensorflow-examples:gpu
# For the tf_cnn_benchmarks usage, see
# https://github.com/tensorflow/benchmarks/tree/master/scripts/tf_cnn_benchmarks
workingDir: /tensorflow/benchmarks/scripts/tf_cnn_benchmarks
# Using /mnt/frameworkbarrier/injector.sh to inject environment variables
# without the need for image invasion and k8s DNS:
# FB_{UpperCase({TaskRoleName})}_ADDRESSES=
# {Task[0].PodIP}:${FB_{UpperCase({TaskRoleName})}_PORT},...,
# {Task[TaskRole.TaskNumber-1].PodIP}:${FB_{UpperCase({TaskRoleName})}_PORT}
# See more in ./example/framework/extension/frameworkbarrier.yaml
command: [
"sh", "-c",
"FB_PS_PORT=4001 FB_WORKER_PORT=5001 . /mnt/frameworkbarrier/injector.sh &&
python tf_cnn_benchmarks.py --job_name=ps --task_index=${FC_TASK_INDEX}
--ps_hosts=${FB_PS_ADDRESSES} --worker_hosts=${FB_WORKER_ADDRESSES}
--variable_update=parameter_server --cross_replica_sync=false
--model=alexnet --batch_size=8 --num_batches=10
--device=gpu --local_parameter_device=gpu --num_gpus=1 --data_format=NCHW
--data_name=cifar10 --data_dir=/mnt/data/cifar-10-batches-py
--train_dir=/mnt/data/${FC_FRAMEWORK_NAME}/output"]
ports:
- containerPort: 4001
resources:
limits:
# [PREREQUISITE]
# User needs to setup GPU for the k8s cluster.
# See https://kubernetes.io/docs/tasks/manage-gpus/scheduling-gpus
nvidia.com/gpu: 1
volumeMounts:
- name: frameworkbarrier-volume
mountPath: /mnt/frameworkbarrier
- name: data-volume
mountPath: /mnt/data
# [PREREQUISITE]
# User needs to create a service account for frameworkbarrier, if the
# k8s cluster enforces authorization.
# See more in ./example/framework/extension/frameworkbarrier.yaml
serviceAccountName: frameworkbarrier
initContainers:
- name: frameworkbarrier
# Using official image to demonstrate this example.
image: frameworkcontroller/frameworkbarrier
# Using k8s inClusterConfig, so usually, no need to specify
# KUBE_APISERVER_ADDRESS or KUBECONFIG
#env:
#- name: KUBE_APISERVER_ADDRESS
# value: {http[s]://host:port}
#- name: KUBECONFIG
# value: {Pod Local KubeConfig File Path}
volumeMounts:
- name: frameworkbarrier-volume
mountPath: /mnt/frameworkbarrier
volumes:
- name: frameworkbarrier-volume
emptyDir: {}
- name: data-volume
# [PREREQUISITE]
# User needs to specify his own data-volume for input data and
# output model.
# The data-volume must be a distributed shared file system, so that
# data can be "handed off" between Pods, such as nfs, cephfs or
# glusterfs, etc.
# See https://kubernetes.io/docs/concepts/storage/volumes.
#
# And then he needs to download and extract the example input data
# from:
# https://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz
# to:
# {Volume Shared Directory}/cifar-10-batches-py
#
# For example:
#nfs:
# server: {NFS Server Host}
# path: {NFS Shared Directory}
- name: worker
taskNumber: 3
frameworkAttemptCompletionPolicy:
minFailedTaskCount: 1
# Succeed the FrameworkAttempt immediately if worker's all Tasks succeeded.
minSucceededTaskCount: 3
task:
retryPolicy:
fancyRetryPolicy: false
maxRetryCount: 0
pod:
spec:
restartPolicy: Never
# [PREREQUISITE]
# Same as ps TaskRole.
hostNetwork: false
containers:
- name: tensorflow
image: frameworkcontroller/tensorflow-examples:gpu
workingDir: /tensorflow/benchmarks/scripts/tf_cnn_benchmarks
command: [
"sh", "-c",
"FB_PS_PORT=4001 FB_WORKER_PORT=5001 . /mnt/frameworkbarrier/injector.sh &&
python tf_cnn_benchmarks.py --job_name=worker --task_index=${FC_TASK_INDEX}
--ps_hosts=${FB_PS_ADDRESSES} --worker_hosts=${FB_WORKER_ADDRESSES}
--variable_update=parameter_server --cross_replica_sync=false
--model=alexnet --batch_size=8 --num_batches=10
--device=gpu --local_parameter_device=gpu --num_gpus=1 --data_format=NCHW
--data_name=cifar10 --data_dir=/mnt/data/cifar-10-batches-py
--train_dir=/mnt/data/${FC_FRAMEWORK_NAME}/output"]
ports:
- containerPort: 5001
resources:
limits:
# [PREREQUISITE]
# Same as ps TaskRole.
nvidia.com/gpu: 1
volumeMounts:
- name: frameworkbarrier-volume
mountPath: /mnt/frameworkbarrier
- name: data-volume
mountPath: /mnt/data
# [PREREQUISITE]
# Same as ps TaskRole.
serviceAccountName: frameworkbarrier
initContainers:
- name: frameworkbarrier
image: frameworkcontroller/frameworkbarrier
#env:
#- name: KUBE_APISERVER_ADDRESS
# value: {http[s]://host:port}
#- name: KUBECONFIG
# value: {Pod Local KubeConfig File Path}
volumeMounts:
- name: frameworkbarrier-volume
mountPath: /mnt/frameworkbarrier
volumes:
- name: frameworkbarrier-volume
emptyDir: {}
- name: data-volume
# [PREREQUISITE]
# Same as ps TaskRole.
#nfs:
# server: {NFS Server Host}
# path: {NFS Shared Directory}