Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
cf515d90
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 2 年 前同步成功
通知
2325
Star
20933
Fork
5424
代码
文件
提交
分支
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看板
未验证
提交
cf515d90
编写于
6月 19, 2023
作者:
C
Chitsing KUI
提交者:
GitHub
6月 19, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[LAUNCH] no endpoints env in dynamic mode (#54636)
* no endpoints in dy mode * fix fleet api inconsistent
上级
855650ec
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
17 addition
and
19 deletion
+17
-19
python/paddle/distributed/fleet/fleet.py
python/paddle/distributed/fleet/fleet.py
+0
-13
python/paddle/distributed/fleet/model.py
python/paddle/distributed/fleet/model.py
+1
-1
python/paddle/distributed/launch/controllers/collective.py
python/paddle/distributed/launch/controllers/collective.py
+6
-2
python/paddle/distributed/parallel.py
python/paddle/distributed/parallel.py
+9
-2
test/legacy_test/test_spawn_and_init_parallel_env.py
test/legacy_test/test_spawn_and_init_parallel_env.py
+1
-1
未找到文件。
python/paddle/distributed/fleet/fleet.py
浏览文件 @
cf515d90
...
@@ -272,20 +272,7 @@ class Fleet:
...
@@ -272,20 +272,7 @@ class Fleet:
self
.
strategy_compiler
=
StrategyCompiler
()
self
.
strategy_compiler
=
StrategyCompiler
()
if
self
.
_role_maker
.
_is_non_distributed
()
and
self
.
_is_collective
:
if
paddle
.
framework
.
core
.
is_compiled_with_cuda
():
gpus_num
=
paddle
.
framework
.
core
.
get_cuda_device_count
()
if
gpus_num
!=
1
:
raise
ValueError
(
"CUDA_VISIBLE_DEVICES shoule be set only 1 card if you use `python` to launch fleet program."
)
if
in_dynamic_mode
():
if
in_dynamic_mode
():
if
self
.
worker_num
()
==
1
:
# if worker_num is 1, should construct default topology & hcg
self
.
_topology
=
tp
.
CommunicateTopology
()
self
.
_hcg
=
tp
.
HybridCommunicateGroup
(
self
.
_topology
)
return
if
parallel_helper
.
_is_parallel_ctx_initialized
():
if
parallel_helper
.
_is_parallel_ctx_initialized
():
logger
.
warning
(
logger
.
warning
(
"The dygraph parallel environment has been initialized."
"The dygraph parallel environment has been initialized."
...
...
python/paddle/distributed/fleet/model.py
浏览文件 @
cf515d90
...
@@ -85,7 +85,7 @@ def distributed_model(model):
...
@@ -85,7 +85,7 @@ def distributed_model(model):
fleet_env
=
fleet
.
fleet
fleet_env
=
fleet
.
fleet
assert
model
is
not
None
,
"model should not be None"
assert
model
is
not
None
,
"model should not be None"
if
fleet_env
.
worker_num
()
<=
1
:
if
paddle
.
distributed
.
get_world_size
()
<=
1
:
return
model
return
model
amp_enable
=
False
amp_enable
=
False
...
...
python/paddle/distributed/launch/controllers/collective.py
浏览文件 @
cf515d90
...
@@ -120,12 +120,14 @@ class CollectiveController(Controller):
...
@@ -120,12 +120,14 @@ class CollectiveController(Controller):
"PADDLE_LOCAL_RANK"
:
f
"
{
i
}
"
,
"PADDLE_LOCAL_RANK"
:
f
"
{
i
}
"
,
"PADDLE_NNODES"
:
f
"
{
len
(
ips
)
}
"
,
"PADDLE_NNODES"
:
f
"
{
len
(
ips
)
}
"
,
# compatible env
# compatible env
"PADDLE_TRAINER_ENDPOINTS"
:
","
.
join
(
job_endpoints
),
"PADDLE_CURRENT_ENDPOINT"
:
job_endpoints
[
i
+
rank_offset
],
"PADDLE_CURRENT_ENDPOINT"
:
job_endpoints
[
i
+
rank_offset
],
"PADDLE_TRAINER_ID"
:
f
"
{
i
+
rank_offset
}
"
,
"PADDLE_TRAINER_ID"
:
f
"
{
i
+
rank_offset
}
"
,
"PADDLE_TRAINERS_NUM"
:
f
"
{
len
(
job_endpoints
)
}
"
,
"PADDLE_TRAINERS_NUM"
:
f
"
{
len
(
job_endpoints
)
}
"
,
"PADDLE_RANK_IN_NODE"
:
str
(
i
),
"PADDLE_RANK_IN_NODE"
:
str
(
i
),
}
}
if
len
(
","
.
join
(
job_endpoints
))
<
120
*
1024
:
e
.
update
({
"PADDLE_TRAINER_ENDPOINTS"
:
","
.
join
(
job_endpoints
)})
if
self
.
_tuner_run_mode
is
not
None
:
if
self
.
_tuner_run_mode
is
not
None
:
e
.
update
(
e
.
update
(
{
{
...
@@ -213,12 +215,14 @@ class CollectiveController(Controller):
...
@@ -213,12 +215,14 @@ class CollectiveController(Controller):
"PADDLE_LOCAL_RANK"
:
f
"
{
i
}
"
,
"PADDLE_LOCAL_RANK"
:
f
"
{
i
}
"
,
"PADDLE_NNODES"
:
f
"
{
self
.
job
.
replicas
}
"
,
"PADDLE_NNODES"
:
f
"
{
self
.
job
.
replicas
}
"
,
# compatible env
# compatible env
"PADDLE_TRAINER_ENDPOINTS"
:
","
.
join
(
job_endpoints
),
"PADDLE_CURRENT_ENDPOINT"
:
endpoints
[
i
],
"PADDLE_CURRENT_ENDPOINT"
:
endpoints
[
i
],
"PADDLE_TRAINER_ID"
:
f
"
{
i
+
rank_offset
}
"
,
"PADDLE_TRAINER_ID"
:
f
"
{
i
+
rank_offset
}
"
,
"PADDLE_TRAINERS_NUM"
:
f
"
{
global_size
}
"
,
"PADDLE_TRAINERS_NUM"
:
f
"
{
global_size
}
"
,
"PADDLE_RANK_IN_NODE"
:
str
(
i
),
"PADDLE_RANK_IN_NODE"
:
str
(
i
),
}
}
if
len
(
","
.
join
(
job_endpoints
))
<
120
*
1024
:
e
.
update
({
"PADDLE_TRAINER_ENDPOINTS"
:
","
.
join
(
job_endpoints
)})
if
self
.
_tuner_run_mode
is
not
None
:
if
self
.
_tuner_run_mode
is
not
None
:
e
.
update
(
e
.
update
(
{
{
...
...
python/paddle/distributed/parallel.py
浏览文件 @
cf515d90
...
@@ -38,7 +38,11 @@ from paddle.distributed.collective import (
...
@@ -38,7 +38,11 @@ from paddle.distributed.collective import (
_set_group_map_by_name
,
_set_group_map_by_name
,
_valid_backend_list
,
_valid_backend_list
,
)
)
from
paddle.distributed.communication.group
import
_add_new_group
from
paddle.distributed.communication.group
import
(
_add_new_group
,
_get_global_group
,
is_initialized
,
)
from
paddle.distributed.fleet.base.private_helper_function
import
(
# noqa: F401
from
paddle.distributed.fleet.base.private_helper_function
import
(
# noqa: F401
wait_server_ready
,
wait_server_ready
,
)
)
...
@@ -1017,7 +1021,6 @@ def init_parallel_env():
...
@@ -1017,7 +1021,6 @@ def init_parallel_env():
_check_var_exists
(
"PADDLE_TRAINER_ID"
)
_check_var_exists
(
"PADDLE_TRAINER_ID"
)
_check_var_exists
(
"PADDLE_CURRENT_ENDPOINT"
)
_check_var_exists
(
"PADDLE_CURRENT_ENDPOINT"
)
_check_var_exists
(
"PADDLE_TRAINERS_NUM"
)
_check_var_exists
(
"PADDLE_TRAINERS_NUM"
)
_check_var_exists
(
"PADDLE_TRAINER_ENDPOINTS"
)
# NOTE(chenweihang): [ why config global place here? ]
# NOTE(chenweihang): [ why config global place here? ]
# the dygraph mode will be set to default mode,
# the dygraph mode will be set to default mode,
...
@@ -1242,6 +1245,10 @@ def get_world_size(group=None):
...
@@ -1242,6 +1245,10 @@ def get_world_size(group=None):
print("The world_size is %d" % dist.get_world_size())
print("The world_size is %d" % dist.get_world_size())
# The world_size is 1
# The world_size is 1
"""
"""
if
in_dynamic_mode
()
and
(
group
is
None
):
if
is_initialized
():
group
=
_get_global_group
()
if
in_dynamic_mode
()
and
group
:
if
in_dynamic_mode
()
and
group
:
return
group
.
world_size
return
group
.
world_size
...
...
test/legacy_test/test_spawn_and_init_parallel_env.py
浏览文件 @
cf515d90
...
@@ -37,7 +37,7 @@ class TestInitParallelEnv(unittest.TestCase):
...
@@ -37,7 +37,7 @@ class TestInitParallelEnv(unittest.TestCase):
def
test_check_env_failed
(
self
):
def
test_check_env_failed
(
self
):
os
.
environ
[
'FLAGS_selected_gpus'
]
=
'0'
os
.
environ
[
'FLAGS_selected_gpus'
]
=
'0'
os
.
environ
[
'PADDLE_TRAINER_ID'
]
=
'0'
os
.
environ
[
'PADDLE_TRAINER_ID'
]
=
'0'
os
.
environ
[
'PADDLE_CURRENT_ENDPOINT'
]
=
'127.0.0.1:6170'
#
os.environ['PADDLE_CURRENT_ENDPOINT'] = '127.0.0.1:6170'
os
.
environ
[
'PADDLE_TRAINERS_NUM'
]
=
'2'
os
.
environ
[
'PADDLE_TRAINERS_NUM'
]
=
'2'
with
self
.
assertRaises
(
ValueError
):
with
self
.
assertRaises
(
ValueError
):
dist
.
init_parallel_env
()
dist
.
init_parallel_env
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录