Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
0fad63a3
P
Paddle
项目概览
机器未来
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
0fad63a3
编写于
6月 25, 2019
作者:
T
tangwei12
提交者:
guru4elephant
6月 25, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix paddle cloud role maker bug (#18269) (#18311)
* fix paddle cloud role maker bug
上级
f6432604
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
31 addition
and
12 deletion
+31
-12
python/paddle/fluid/incubate/fleet/base/role_maker.py
python/paddle/fluid/incubate/fleet/base/role_maker.py
+31
-12
未找到文件。
python/paddle/fluid/incubate/fleet/base/role_maker.py
浏览文件 @
0fad63a3
...
...
@@ -19,6 +19,8 @@ __all__ = [
'UserDefinedCollectiveRoleMaker'
,
'PaddleCloudRoleMaker'
]
import
os
class
Role
:
WORKER
=
1
...
...
@@ -295,45 +297,62 @@ class MPISymetricRoleMaker(MPIRoleMaker):
class
PaddleCloudRoleMaker
(
RoleMakerBase
):
def
__init__
(
self
):
super
(
PaddleCloudRoleMaker
,
self
).
__init__
()
self
.
_role_is_generated
=
False
def
generate_role
(
self
):
if
not
self
.
_role_is_generated
:
self
.
port
=
os
.
getenv
(
"PADDLE_PORT"
,
"6174"
)
self
.
pserver_ips
=
os
.
getenv
(
"PADDLE_PSERVERS"
,
""
)
eplist
=
[]
for
ip
in
pserver_ips
.
split
(
","
):
eplist
.
append
(
':'
.
join
([
ip
,
port
]))
self
.
endpoints
=
","
.
join
(
eplist
)
self
.
trainers
=
int
(
os
.
getenv
(
"PADDLE_TRAINERS_NUM"
,
"1"
))
self
.
current_endpoint
=
os
.
getenv
(
"POD_IP"
,
"localhost"
)
+
":"
+
port
self
.
role
=
os
.
getenv
(
"TRAINING_ROLE"
,
"TRAINER"
)
self
.
trainer_id
=
int
(
os
.
getenv
(
"PADDLE_TRAINER_ID"
,
"0"
))
for
ip
in
self
.
pserver_ips
.
split
(
","
):
eplist
.
append
(
':'
.
join
([
ip
,
self
.
port
]))
self
.
endpoints
=
","
.
join
(
eplist
)
self
.
_
trainers
=
int
(
os
.
getenv
(
"PADDLE_TRAINERS_NUM"
,
"1"
))
self
.
current_endpoint
=
os
.
getenv
(
"POD_IP"
,
"localhost"
)
+
":"
+
self
.
port
self
.
role
=
os
.
getenv
(
"TRAINING_ROLE"
,
"TRAINER"
)
self
.
trainer_id
=
int
(
os
.
getenv
(
"PADDLE_TRAINER_ID"
,
"0"
))
self
.
eplist
=
eplist
print
(
"PaddleCloudRoleMaker() endpoints: %s"
%
self
.
endpoints
)
self
.
endpoints
=
self
.
endpoints
.
split
(
","
)
self
.
_server_endpoints
=
self
.
endpoints
if
self
.
role
.
upper
()
==
"PSERVER"
:
self
.
current_id
=
self
.
endpoints
.
index
(
self
.
current_endpoint
)
self
.
_current_id
=
self
.
endpoints
.
index
(
self
.
current_endpoint
)
self
.
_role
=
Role
.
SERVER
else
:
self
.
current_id
=
self
.
trainer_id
self
.
_current_id
=
self
.
trainer_id
self
.
_role
=
Role
.
WORKER
self
.
_role_is_generated
=
True
def
is_wokrer
(
self
):
def
is_worker
(
self
):
if
not
self
.
_role_is_generated
:
self
.
generate_role
()
return
self
.
_role
==
Role
.
WORKER
def
is_server
(
self
):
if
not
self
.
_role_is_generated
:
self
.
generate_role
()
return
self
.
_role
==
Role
.
SERVER
def
is_first_worker
(
self
):
if
not
self
.
_role_is_generated
:
self
.
generate_role
()
return
self
.
_role
==
Role
.
WORKER
and
self
.
_current_id
==
0
def
worker_index
(
self
):
if
not
self
.
_role_is_generated
:
self
.
generate_role
()
return
self
.
_current_id
def
server_index
(
self
):
if
not
self
.
_role_is_generated
:
self
.
generate_role
()
return
self
.
_current_id
def
worker_num
(
self
):
return
self
.
_worker_num
if
not
self
.
_role_is_generated
:
self
.
generate_role
()
return
self
.
_trainers
class
UserDefinedRoleMaker
(
RoleMakerBase
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录