Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
dd4cd352
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
dd4cd352
编写于
6月 08, 2019
作者:
G
gongweibao
提交者:
GitHub
6月 08, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix sync_batch_norm_op ncclallreduce error! (#17918)
上级
f3e5a5cf
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
30 addition
and
3 deletion
+30
-3
paddle/fluid/framework/parallel_executor.cc
paddle/fluid/framework/parallel_executor.cc
+23
-2
paddle/fluid/framework/parallel_executor.h
paddle/fluid/framework/parallel_executor.h
+7
-1
未找到文件。
paddle/fluid/framework/parallel_executor.cc
浏览文件 @
dd4cd352
...
@@ -281,6 +281,27 @@ bool ParallelExecutor::NeedCreateLocalExeScope() {
...
@@ -281,6 +281,27 @@ bool ParallelExecutor::NeedCreateLocalExeScope() {
return
executor
&&
executor
->
NeedCreateLocalExeScope
();
return
executor
&&
executor
->
NeedCreateLocalExeScope
();
}
}
#if defined(PADDLE_WITH_CUDA) && !defined(_WIN32)
/*
* When nccl inits nccl comm using ncclCommInitAll, it meets error when
* allreduce ophandle and sync_batch_norm_op use ncclallreduce parallelly. So
* create a new nccl comm for sync_batch_norm_op. And these codes should be
* polished with a unified nccl management.
*/
platform
::
NCCLContextMap
*
ParallelExecutor
::
GetNCCLContextForSyncbatchNomrOp
(
framework
::
Scope
*
scope
)
{
auto
*
nccl_id_var
=
scope
->
FindVar
(
NCCL_ID_VARNAME
);
if
(
nccl_id_var
!=
nullptr
)
{
return
member_
->
nccl_ctxs_
.
DefaultFlatCtx
();
}
if
(
dev_nccl_ctxs_
.
get
()
==
nullptr
)
{
dev_nccl_ctxs_
.
reset
(
new
platform
::
NCCLContextMap
(
member_
->
places_
));
}
return
dev_nccl_ctxs_
.
get
();
}
#endif
ParallelExecutor
::
ParallelExecutor
(
const
std
::
vector
<
platform
::
Place
>
&
places
,
ParallelExecutor
::
ParallelExecutor
(
const
std
::
vector
<
platform
::
Place
>
&
places
,
const
std
::
vector
<
std
::
string
>
&
bcast_vars
,
const
std
::
vector
<
std
::
string
>
&
bcast_vars
,
const
std
::
string
&
loss_var_name
,
const
std
::
string
&
loss_var_name
,
...
@@ -357,13 +378,13 @@ ParallelExecutor::ParallelExecutor(const std::vector<platform::Place> &places,
...
@@ -357,13 +378,13 @@ ParallelExecutor::ParallelExecutor(const std::vector<platform::Place> &places,
// NOTE: NCCL group-calls and non-group-calls can not use the same
// NOTE: NCCL group-calls and non-group-calls can not use the same
// NCCL communicator, so for ParallelGraph and Multi-Process mode, re-use
// NCCL communicator, so for ParallelGraph and Multi-Process mode, re-use
// same communicators.
// same communicators.
auto
*
nccl_ctxs
=
GetNCCLContextForSyncbatchNomrOp
(
scope
);
for
(
size_t
dev_id
=
0
;
dev_id
<
member_
->
places_
.
size
();
++
dev_id
)
{
for
(
size_t
dev_id
=
0
;
dev_id
<
member_
->
places_
.
size
();
++
dev_id
)
{
platform
::
DeviceContextPool
&
pool
=
platform
::
DeviceContextPool
&
pool
=
platform
::
DeviceContextPool
::
Instance
();
platform
::
DeviceContextPool
::
Instance
();
auto
*
dev_ctx
=
static_cast
<
platform
::
CUDADeviceContext
*>
(
auto
*
dev_ctx
=
static_cast
<
platform
::
CUDADeviceContext
*>
(
pool
.
Get
(
member_
->
places_
[
dev_id
]));
pool
.
Get
(
member_
->
places_
[
dev_id
]));
auto
&
nccl_ctx
=
auto
&
nccl_ctx
=
nccl_ctxs
->
at
(
member_
->
places_
[
dev_id
]);
member_
->
nccl_ctxs_
.
DefaultFlatCtx
()
->
at
(
member_
->
places_
[
dev_id
]);
dev_ctx
->
set_nccl_comm
(
nccl_ctx
.
comm
());
dev_ctx
->
set_nccl_comm
(
nccl_ctx
.
comm
());
}
}
#endif
#endif
...
...
paddle/fluid/framework/parallel_executor.h
浏览文件 @
dd4cd352
...
@@ -87,7 +87,13 @@ class ParallelExecutor {
...
@@ -87,7 +87,13 @@ class ParallelExecutor {
ParallelExecutorPrivate
*
member_
;
ParallelExecutorPrivate
*
member_
;
std
::
vector
<
std
::
unique_ptr
<
ir
::
Graph
>>
async_graphs_
;
std
::
vector
<
std
::
unique_ptr
<
ir
::
Graph
>>
async_graphs_
;
};
#if defined(PADDLE_WITH_CUDA) && !defined(_WIN32)
// used for compatible with syncbatch norm op
std
::
unique_ptr
<
platform
::
NCCLContextMap
>
dev_nccl_ctxs_
;
platform
::
NCCLContextMap
*
GetNCCLContextForSyncbatchNomrOp
(
framework
::
Scope
*
scope
);
#endif
};
}
// namespace framework
}
// namespace framework
}
// namespace paddle
}
// namespace paddle
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录