Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
bff4179c
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2297
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
bff4179c
编写于
11月 23, 2020
作者:
C
Chen Weihang
提交者:
GitHub
11月 23, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
lazily init global group in collective (#28780)
上级
a22ea652
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
15 addition
and
4 deletion
+15
-4
python/paddle/distributed/collective.py
python/paddle/distributed/collective.py
+15
-4
未找到文件。
python/paddle/distributed/collective.py
浏览文件 @
bff4179c
...
...
@@ -81,9 +81,19 @@ class _Group():
self
.
nranks
=
rank_num
_default_group
=
_Group
(
# NOTE(chenweihang): Lazily initialized global group information
# If we initialize _default_group when import module, it will
# not update when we use spawn to run multi-process training
_default_group
=
None
def
_get_global_default_group
():
global
_default_group
if
_default_group
is
None
:
_default_group
=
_Group
(
int
(
os
.
getenv
(
"PADDLE_TRAINER_ID"
,
"0"
)),
int
(
os
.
getenv
(
"PADDLE_TRAINERS_NUM"
,
"1"
)))
return
_default_group
def
broadcast
(
tensor
,
src
,
group
=
0
):
...
...
@@ -339,6 +349,7 @@ def all_gather(tensor_list, tensor, group=0):
op_type
=
'c_allgather'
helper
=
LayerHelper
(
op_type
,
**
locals
())
out
=
helper
.
create_variable_for_type_inference
(
dtype
=
tensor
.
dtype
)
_default_group
=
_get_global_default_group
()
if
in_dygraph_mode
():
core
.
ops
.
c_allgather
(
tensor
,
out
,
'use_calc_stream'
,
True
,
'ring_id'
,
group
,
'nranks'
,
_default_group
.
nranks
)
...
...
@@ -410,7 +421,7 @@ def scatter(tensor, tensor_list=None, src=0, group=0):
out = data1.numpy()
"""
op_type
=
'c_scatter'
global
_default_group
_default_group
=
_get_global_default_group
()
rank
=
_default_group
.
rank
nranks
=
_default_group
.
nranks
if
rank
!=
src
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录