Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
67bf06ce
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
67bf06ce
编写于
1月 26, 2017
作者:
H
Helin Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
paddle on aws with kubernetes tutorial now works
上级
f4ff8d26
变更
12
展开全部
隐藏空白更改
内联
并排
Showing
12 changed file
with
331 addition
and
362 deletion
+331
-362
doc/howto/usage/k8s/k8s_aws_en.md
doc/howto/usage/k8s/k8s_aws_en.md
+255
-304
doc/howto/usage/k8s/src/add_security_group.png
doc/howto/usage/k8s/src/add_security_group.png
+0
-0
doc/howto/usage/k8s/src/create_efs.png
doc/howto/usage/k8s/src/create_efs.png
+0
-0
doc/howto/usage/k8s/src/job.yaml
doc/howto/usage/k8s/src/job.yaml
+0
-43
doc/howto/usage/k8s/src/k8s_data/Dockerfile
doc/howto/usage/k8s/src/k8s_data/Dockerfile
+7
-0
doc/howto/usage/k8s/src/k8s_data/README.md
doc/howto/usage/k8s/src/k8s_data/README.md
+6
-0
doc/howto/usage/k8s/src/k8s_data/get_data.sh
doc/howto/usage/k8s/src/k8s_data/get_data.sh
+26
-0
doc/howto/usage/k8s/src/k8s_train/Dockerfile
doc/howto/usage/k8s/src/k8s_train/Dockerfile
+6
-0
doc/howto/usage/k8s/src/k8s_train/README.md
doc/howto/usage/k8s/src/k8s_train/README.md
+5
-0
doc/howto/usage/k8s/src/k8s_train/start.sh
doc/howto/usage/k8s/src/k8s_train/start.sh
+6
-6
doc/howto/usage/k8s/src/k8s_train/start_paddle.py
doc/howto/usage/k8s/src/k8s_train/start_paddle.py
+20
-9
doc/howto/usage/k8s/src/worker_security_group.png
doc/howto/usage/k8s/src/worker_security_group.png
+0
-0
未找到文件。
doc/howto/usage/k8s/k8s_aws_en.md
浏览文件 @
67bf06ce
此差异已折叠。
点击以展开。
doc/howto/usage/k8s/src/add_security_group.png
查看替换文件 @
f4ff8d26
浏览文件 @
67bf06ce
231.9 KB
|
W:
|
H:
116.2 KB
|
W:
|
H:
2-up
Swipe
Onion skin
doc/howto/usage/k8s/src/create_efs.png
查看替换文件 @
f4ff8d26
浏览文件 @
67bf06ce
244.5 KB
|
W:
|
H:
236.1 KB
|
W:
|
H:
2-up
Swipe
Onion skin
doc/howto/usage/k8s/src/job.yaml
已删除
100644 → 0
浏览文件 @
f4ff8d26
apiVersion
:
batch/v1
kind
:
Job
metadata
:
name
:
paddle-cluster-job
spec
:
parallelism
:
3
completions
:
3
template
:
metadata
:
name
:
paddle-cluster-job
spec
:
volumes
:
-
name
:
jobpath
hostPath
:
path
:
/home/work/paddle_output
containers
:
-
name
:
trainer
image
:
registry.baidu.com/public/paddle:mypaddle
command
:
[
"
bin/bash"
,
"
-c"
,
"
/root/start.sh"
]
env
:
-
name
:
JOB_NAME
value
:
paddle-cluster-job
-
name
:
JOB_PATH
value
:
/home/jobpath
-
name
:
JOB_NAMESPACE
value
:
default
-
name
:
TRAIN_CONFIG_DIR
value
:
recommendation
-
name
:
CONF_PADDLE_NIC
value
:
eth0
-
name
:
CONF_PADDLE_PORT
value
:
"
7164"
-
name
:
CONF_PADDLE_PORTS_NUM
value
:
"
2"
-
name
:
CONF_PADDLE_PORTS_NUM_SPARSE
value
:
"
2"
-
name
:
CONF_PADDLE_GRADIENT_NUM
value
:
"
3"
volumeMounts
:
-
name
:
jobpath
mountPath
:
/home/jobpath
restartPolicy
:
Never
doc/howto/usage/k8s/src/k8s_data/Dockerfile
0 → 100644
浏览文件 @
67bf06ce
FROM
alpine
RUN
apk update
&&
apk upgrade
&&
apk add coreutils
ADD
quick_start /quick_start
ADD
get_data.sh /bin/
RUN
chmod
+x /bin/get_data.sh
ENTRYPOINT
["/bin/get_data.sh"]
doc/howto/usage/k8s/src/k8s_data/README.md
0 → 100644
浏览文件 @
67bf06ce
To build PaddlePaddle data preparation image in tutorial
[
Distributed PaddlePaddle Training on AWS with Kubernetes
](
../k8s_aws_en.md
)
, run following commands:
```
cp -r ../../../../../../demo/quick_start .
docker build . -t prepare-data-image-name
```
doc/howto/usage/k8s/src/k8s_data/get_data.sh
0 → 100755
浏览文件 @
67bf06ce
#!/bin/sh
out_dir
=
$OUT_DIR
split_count
=
$SPLIT_COUNT
set
-e
mkdir
-p
$out_dir
cp
-r
/quick_start
$out_dir
/
mkdir
-p
$out_dir
/0/data
cd
$out_dir
/0/data
wget http://paddlepaddle.bj.bcebos.com/demo/quick_start_preprocessed_data/preprocessed_data.tar.gz
tar
zxvf preprocessed_data.tar.gz
rm
preprocessed_data.tar.gz
split
-d
--number
=
l/
$split_count
-a
5 train.txt train.
mv
train.00000 train.txt
cd
$out_dir
end
=
$(
expr
$split_count
- 1
)
for
i
in
$(
seq
1
$end
)
;
do
mkdir
-p
$i
/data
cp
-r
0/data/
*
$i
/data
mv
$i
/data/train.
`
printf
%05d
$i
`
$i
/data/train.txt
done
;
doc/howto/usage/k8s/src/k8s_train/Dockerfile
0 → 100644
浏览文件 @
67bf06ce
FROM
paddledev/paddle:cpu-latest
COPY
start.sh /root/
COPY
start_paddle.py /root/
RUN
chmod
+x /root/start.sh
CMD
["bash"," -c","/root/start.sh"]
doc/howto/usage/k8s/src/k8s_train/README.md
0 → 100644
浏览文件 @
67bf06ce
To build PaddlePaddle training image in tutorial
[
Distributed PaddlePaddle Training on AWS with Kubernetes
](
../k8s_aws_en.md
)
, run following command:
```
docker build . -t train-image-name
```
doc/howto/usage/k8s/src/start.sh
→
doc/howto/usage/k8s/src/
k8s_train/
start.sh
浏览文件 @
67bf06ce
#!/bin/sh
set
-eu
jobconfig
=
${
JOB_PATH
}
"/"
${
JOB_NAME
}
"/"
${
TRAIN_CONFIG_DIR
}
cd
/root
cp
-rf
$jobconfig
.
cd
$TRAIN_CONFIG_DIR
cp
-rf
$jobconfig
/
*
.
python /root/start_paddle.py
\
--dot_period
=
10
\
--ports_num_for_sparse
=
$CONF_PADDLE_PORTS_NUM
\
--ports_num
=
$CONF_PADDLE_PORTS_NUM
\
--ports_num_for_sparse
=
$CONF_PADDLE_PORTS_NUM_SPARSE
\
--log_period
=
50
\
--num_passes
=
10
\
--trainer_count
=
4
\
--trainer_count
=
$TRAINER_COUNT
\
--saving_period
=
1
\
--local
=
0
\
--config
=
./trainer_config
.py
\
--config
=
trainer_config.lr
.py
\
--use_gpu
=
0
doc/howto/usage/k8s/src/start_paddle.py
→
doc/howto/usage/k8s/src/
k8s_train/
start_paddle.py
浏览文件 @
67bf06ce
...
...
@@ -23,7 +23,6 @@ import argparse
API
=
"/api/v1/namespaces/"
JOBSELECTOR
=
"labelSelector=job-name="
JOB_PATH
=
os
.
getenv
(
"JOB_PATH"
)
+
"/"
+
os
.
getenv
(
"JOB_NAME"
)
JOB_PATH_DATA
=
JOB_PATH
+
"/data"
JOB_PATH_OUTPUT
=
JOB_PATH
+
"/output"
JOBNAME
=
os
.
getenv
(
"JOB_NAME"
)
NAMESPACE
=
os
.
getenv
(
"JOB_NAMESPACE"
)
...
...
@@ -33,6 +32,8 @@ PADDLE_PORTS_NUM = os.getenv("CONF_PADDLE_PORTS_NUM")
PADDLE_PORTS_NUM_SPARSE
=
os
.
getenv
(
"CONF_PADDLE_PORTS_NUM_SPARSE"
)
PADDLE_SERVER_NUM
=
os
.
getenv
(
"CONF_PADDLE_GRADIENT_NUM"
)
tokenpath
=
'/var/run/secrets/kubernetes.io/serviceaccount/token'
def
refine_unknown_args
(
cmd_args
):
'''
...
...
@@ -64,6 +65,7 @@ def isPodAllRunning(podlist):
for
pod
in
podlist
[
"items"
]:
if
pod
[
"status"
][
"phase"
]
==
"Running"
:
running
+=
1
print
"waiting for pods running, require:"
,
require
,
"running:"
,
running
if
require
==
running
:
return
True
return
False
...
...
@@ -79,8 +81,17 @@ def getPodList():
pod
=
API
+
NAMESPACE
+
"/pods?"
job
=
JOBNAME
return
requests
.
get
(
apiserver
+
pod
+
JOBSELECTOR
+
job
,
verify
=
False
).
json
()
if
os
.
path
.
isfile
(
tokenpath
):
tokenfile
=
open
(
tokenpath
,
mode
=
'r'
)
token
=
tokenfile
.
read
()
Bearer
=
"Bearer "
+
token
headers
=
{
"Authorization"
:
Bearer
}
return
requests
.
get
(
apiserver
+
pod
+
JOBSELECTOR
+
job
,
headers
=
headers
,
verify
=
False
).
json
()
else
:
return
requests
.
get
(
apiserver
+
pod
+
JOBSELECTOR
+
job
,
verify
=
False
).
json
()
def
getIdMap
(
podlist
):
...
...
@@ -122,8 +133,8 @@ def startPaddle(idMap={}, train_args_dict=None):
if
not
os
.
path
.
exists
(
JOB_PATH_OUTPUT
):
os
.
makedirs
(
JOB_PATH_OUTPUT
)
os
.
mkdir
(
logDir
)
copyCommand
=
'cp -rf '
+
JOB_PATH
_DATA
+
\
"/"
+
str
(
trainerId
)
+
"
./data
"
copyCommand
=
'cp -rf '
+
JOB_PATH
+
\
"/"
+
str
(
trainerId
)
+
"
/data/*"
+
" ./data/
"
os
.
system
(
copyCommand
)
startPserver
=
'nohup paddle pserver'
+
\
" --port="
+
str
(
PADDLE_PORT
)
+
\
...
...
@@ -136,9 +147,9 @@ def startPaddle(idMap={}, train_args_dict=None):
print
startPserver
os
.
system
(
startPserver
)
# wait until pservers completely start
time
.
sleep
(
1
0
)
startTrainer
=
program
+
args
+
"
>
"
+
\
logDir
+
"/train.log
2>&1 < /dev/null
"
time
.
sleep
(
2
0
)
startTrainer
=
program
+
args
+
"
2>&1 | tee
"
+
\
logDir
+
"/train.log"
print
startTrainer
os
.
system
(
startTrainer
)
...
...
@@ -152,7 +163,7 @@ if __name__ == '__main__':
podlist
=
getPodList
()
# need to wait until all pods are running
while
not
isPodAllRunning
(
podlist
):
time
.
sleep
(
1
0
)
time
.
sleep
(
2
0
)
podlist
=
getPodList
()
idMap
=
getIdMap
(
podlist
)
startPaddle
(
idMap
,
train_args_dict
)
doc/howto/usage/k8s/src/worker_security_group.png
0 → 100644
浏览文件 @
67bf06ce
87.1 KB
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录