Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OPTHREE
Paddle
提交
30562e37
P
Paddle
项目概览
OPTHREE
/
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
30562e37
编写于
7月 25, 2019
作者:
G
guru4elephant
提交者:
GitHub
7月 25, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refine launch_ps and role_maker (#18795)
refine launch_ps and role_maker
上级
292dfbce
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
52 addition
and
17 deletion
+52
-17
python/paddle/distributed/launch_ps.py
python/paddle/distributed/launch_ps.py
+23
-9
python/paddle/fluid/incubate/fleet/base/role_maker.py
python/paddle/fluid/incubate/fleet/base/role_maker.py
+29
-8
未找到文件。
python/paddle/distributed/launch_ps.py
浏览文件 @
30562e37
...
...
@@ -48,6 +48,9 @@ def parse_args():
default
=
True
,
help
=
"Print the config or not"
)
parser
.
add_argument
(
"--endpoints"
,
type
=
str
,
default
=
""
,
help
=
"User defined endpoints"
)
parser
.
add_argument
(
"--worker_num"
,
type
=
int
,
default
=
2
,
help
=
"number of workers"
)
...
...
@@ -87,13 +90,23 @@ def start_procs(args):
cmds
=
[]
log_fns
=
[]
ports
=
range
(
start_port
,
start_port
+
server_num
,
1
)
endpoints
=
","
.
join
([
"127.0.0.1:"
+
str
(
x
)
for
x
in
ports
])
default_endpoints
=
","
.
join
([
"127.0.0.1:"
+
str
(
x
)
for
x
in
ports
])
user_endpoints
=
""
if
args
.
endpoints
==
""
:
user_endpoints
=
default_endpoints
else
:
user_endpoints
=
args
.
endpoints
user_endpoints_ips
=
[
x
.
split
(
":"
)[
0
]
for
x
in
user_endpoints
.
split
(
","
)]
user_endpoints_port
=
[
x
.
split
(
":"
)[
1
]
for
x
in
user_endpoints
.
split
(
","
)]
for
i
in
range
(
server_num
):
current_env
.
update
({
"TRAINER_NUM"
:
str
(
worker_num
),
"CURRENT_ID"
:
str
(
i
),
"ENDPOINTS"
:
endpoints
,
"TRAINING_ROLE"
:
"PSERVER"
"PADDLE_TRAINERS_NUM"
:
str
(
server_num
),
"PADDLE_PORT"
:
","
.
join
(
user_endpoints_port
),
#"POD_IP": user_endpoints_ips[i],
"CURRENT_ENDPOINT"
:
user_endpoints_ips
[
i
]
+
":"
+
user_endpoints_port
[
i
],
"PADDLE_PSERVERS"
:
","
.
join
(
user_endpoints_ips
),
"PADDLE_TRAINING_ROLE"
:
"PSERVER"
})
cmd
=
[
sys
.
executable
,
"-u"
,
args
.
training_script
]
+
args
.
training_script_args
...
...
@@ -110,10 +123,11 @@ def start_procs(args):
for
i
in
range
(
worker_num
):
current_env
.
update
({
"ENDPOINTS"
:
endpoints
,
"TRAINER_NUM"
:
str
(
worker_num
),
"TRAINING_ROLE"
:
"TRAINER"
,
"CURRENT_ID"
:
str
(
i
)
"PADDLE_PSERVERS"
:
","
.
join
(
user_endpoints_ips
),
"PADDLE_PORT"
:
","
.
join
(
user_endpoints_port
),
"PADDLE_TRAINERS_NUM"
:
str
(
worker_num
),
"PADDLE_TRAINING_ROLE"
:
"TRAINER"
,
"PADDLE_TRAINER_ID"
:
str
(
i
)
})
cmd
=
[
sys
.
executable
,
"-u"
,
args
.
training_script
]
+
args
.
training_script_args
...
...
python/paddle/fluid/incubate/fleet/base/role_maker.py
浏览文件 @
30562e37
...
...
@@ -334,25 +334,41 @@ class PaddleCloudRoleMaker(RoleMakerBase):
def
generate_role
(
self
):
if
not
self
.
_role_is_generated
:
if
not
self
.
_is_collective
:
self
.
port
=
os
.
getenv
(
"PADDLE_PORT"
,
"6174"
)
self
.
pserver_ips
=
os
.
getenv
(
"PADDLE_PSERVERS"
,
""
)
self
.
port
=
os
.
getenv
(
"PADDLE_PORT"
,
"6174"
)
# port of current server
self
.
pserver_ips
=
os
.
getenv
(
"PADDLE_PSERVERS"
,
""
)
# ip of server
if
","
in
self
.
port
:
ports
=
self
.
port
.
split
(
","
)
else
:
ports
=
[
self
.
port
for
i
in
self
.
pserver_ips
.
split
(
","
)]
eplist
=
[]
for
ip
in
self
.
pserver_ips
.
split
(
","
):
eplist
.
append
(
':'
.
join
([
ip
,
self
.
port
]))
# note that, we usually assign the same port to different ips
# if we run parameter server training in local mode
# port should be different in environment variables
for
i
,
ip
in
enumerate
(
self
.
pserver_ips
.
split
(
","
)):
eplist
.
append
(
':'
.
join
([
ip
,
ports
[
i
]]))
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"
)
# ip of current node, either a worker or a pserver
current_ip
=
os
.
getenv
(
"POD_IP"
,
""
)
if
current_ip
==
""
:
self
.
_current_endpoint
=
os
.
getenv
(
"CURRENT_ENDPOINT"
)
else
:
self
.
_current_endpoint
=
current_ip
+
ports
[
0
]
self
.
role
=
os
.
getenv
(
"PADDLE_TRAINING_ROLE"
,
"TRAINER"
)
# for trainer, only POD_IP and current trainer id is needed
# we usually do not need to know other trainer ips
self
.
trainer_id
=
int
(
os
.
getenv
(
"PADDLE_TRAINER_ID"
,
"0"
))
self
.
eplist
=
eplist
self
.
endpoints
=
self
.
endpoints
.
split
(
","
)
self
.
_server_endpoints
=
self
.
endpoints
self
.
_worker_endpoints
=
self
.
endpoints
if
self
.
role
.
upper
()
==
"PSERVER"
:
# current endpoint index among all pservers
self
.
_current_id
=
self
.
endpoints
.
index
(
self
.
current_endpoint
)
self
.
_
current_endpoint
)
self
.
_role
=
Role
.
SERVER
else
:
self
.
_current_id
=
self
.
trainer_id
...
...
@@ -369,6 +385,11 @@ class PaddleCloudRoleMaker(RoleMakerBase):
self
.
_num_trainers
=
len
(
self
.
_worker_endpoints
)
self
.
_role_is_generated
=
True
def
get_pserver_endpoints
(
self
):
if
not
self
.
_role_is_generated
:
self
.
generate_role
()
return
self
.
_server_endpoints
def
is_worker
(
self
):
if
not
self
.
_role_is_generated
:
self
.
generate_role
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录