Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleFL
提交
a6b2ae39
P
PaddleFL
项目概览
PaddlePaddle
/
PaddleFL
通知
35
Star
5
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
6
列表
看板
标记
里程碑
合并请求
4
Wiki
3
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleFL
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
6
Issue
6
列表
看板
标记
里程碑
合并请求
4
合并请求
4
Pages
分析
分析
仓库分析
DevOps
Wiki
3
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
a6b2ae39
编写于
2月 26, 2020
作者:
Q
qjing666
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add k8s deployment solution
上级
1e5d5f89
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
0 addition
and
55 deletion
+0
-55
paddle_fl/examples/k8s_deployment/trainer/fl_trainer.py
paddle_fl/examples/k8s_deployment/trainer/fl_trainer.py
+0
-41
paddle_fl/examples/k8s_deployment/trainer/run_trainer.sh
paddle_fl/examples/k8s_deployment/trainer/run_trainer.sh
+0
-14
未找到文件。
paddle_fl/examples/k8s_deployment/trainer/fl_trainer.py
已删除
100644 → 0
浏览文件 @
1e5d5f89
from
paddle_fl.core.trainer.fl_trainer
import
FLTrainerFactory
from
paddle_fl.core.master.fl_job
import
FLRunTimeJob
import
numpy
as
np
import
sys
import
logging
import
time
logging
.
basicConfig
(
filename
=
"test.log"
,
filemode
=
"w"
,
format
=
"%(asctime)s %(name)s:%(levelname)s:%(message)s"
,
datefmt
=
"%d-%M-%Y %H:%M:%S"
,
level
=
logging
.
DEBUG
)
def
reader
():
for
i
in
range
(
1000
):
data_dict
=
{}
for
i
in
range
(
3
):
data_dict
[
str
(
i
)]
=
np
.
random
.
rand
(
1
,
5
).
astype
(
'float32'
)
data_dict
[
"label"
]
=
np
.
random
.
randint
(
2
,
size
=
(
1
,
1
)).
astype
(
'int64'
)
yield
data_dict
trainer_id
=
int
(
sys
.
argv
[
1
])
# trainer id for each guest
job_path
=
"fl_job_config"
job
=
FLRunTimeJob
()
job
.
load_trainer_job
(
job_path
,
trainer_id
)
#job._scheduler_ep = "127.0.0.1:9091" # Inform the scheduler IP to trainer
job
.
_scheduler_ep
=
os
.
environ
[
'FL_SCHEDULER_SERVICE_HOST'
]
+
":"
+
os
.
environ
[
'FL_SCHEDULER_SERVICE_PORT_FL_SCHEDULER'
]
trainer
=
FLTrainerFactory
().
create_fl_trainer
(
job
)
trainer
.
_current_ep
=
"127.0.0.1:{}"
.
format
(
9000
+
trainer_id
)
trainer
.
start
()
print
(
trainer
.
_scheduler_ep
,
trainer
.
_current_ep
)
output_folder
=
"fl_model"
epoch_id
=
0
while
not
trainer
.
stop
():
print
(
"batch %d start train"
%
(
epoch_id
))
train_step
=
0
for
data
in
reader
():
trainer
.
run
(
feed
=
data
,
fetch
=
[])
train_step
+=
1
if
train_step
==
trainer
.
_step
:
break
epoch_id
+=
1
if
epoch_id
%
5
==
0
:
trainer
.
save_inference_program
(
output_folder
)
paddle_fl/examples/k8s_deployment/trainer/run_trainer.sh
已删除
100644 → 0
浏览文件 @
1e5d5f89
#Download config file
wget
#Download image
sudo
docker pull
[
paddle-fl image]
#Build docker
sudo
docker run
--name
paddlefl
-it
-v
$PWD
:/root
[
paddle-fl image] /bin/bash
sudo
docker
cp
/path/to/config paddlefl:/path/to/config/file/at/container
#Run program
python
-u
fl_trainer.py
>
trainer.log &
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录