Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleDetection
提交
c15d2c9e
P
PaddleDetection
项目概览
s920243400
/
PaddleDetection
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleDetection
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
c15d2c9e
编写于
3月 16, 2018
作者:
Y
Yu Yang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update
上级
d470763f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
21 addition
and
13 deletion
+21
-13
paddle/fluid/framework/parallel_executor.cc
paddle/fluid/framework/parallel_executor.cc
+21
-13
未找到文件。
paddle/fluid/framework/parallel_executor.cc
浏览文件 @
c15d2c9e
...
...
@@ -171,27 +171,28 @@ class ParallelExecutorPrivate {
return
boost
::
get
<
platform
::
CUDAPlace
>
(
ctx_
->
GetPlace
()).
device
;
}
static
void
InitNCCLContext
(
std
::
map
<
int
,
NCCLContext
>
&
contexts
)
{
static
void
InitNCCLContext
(
std
::
unordered_map
<
int
,
NCCLContext
>
&
contexts
,
const
std
::
vector
<
platform
::
Place
>
&
places
)
{
std
::
vector
<
ncclComm_t
>
comms
;
std
::
vector
<
int
>
devs
;
comms
.
resize
(
contexts
.
size
());
devs
.
reserve
(
contexts
.
size
());
for
(
auto
&
ctx
:
context
s
)
{
devs
.
push_back
(
ctx
.
first
);
for
(
auto
&
p
:
place
s
)
{
devs
.
push_back
(
boost
::
get
<
platform
::
CUDAPlace
>
(
p
).
device
);
}
NCCL_INVOKE
(
platform
::
dynload
::
ncclCommInitAll
(
&
comms
[
0
],
static_cast
<
int
>
(
contexts
.
size
()),
&
devs
[
0
]));
int
i
=
0
;
for
(
auto
&
ctx
:
context
s
)
{
c
tx
.
second
.
comm
=
comms
[
i
++
];
for
(
auto
&
dev_id
:
dev
s
)
{
c
ontexts
.
at
(
dev_id
)
.
comm
=
comms
[
i
++
];
}
}
};
std
::
map
<
int
,
NCCLContext
>
communication_streams_
;
std
::
unordered_
map
<
int
,
NCCLContext
>
communication_streams_
;
NCCLContext
&
GetNCCLCtx
(
platform
::
Place
p
)
{
int
dev_id
=
boost
::
get
<
platform
::
CUDAPlace
>
(
p
).
device
;
...
...
@@ -493,13 +494,20 @@ void ParallelExecutor::BCastParamsToGPUs(
platform
::
dynload
::
ncclGroupStart
();
for
(
auto
&
place
:
member_
->
places_
)
{
auto
local_scope
=
member_
->
local_scopes_
[
place
];
auto
*
t
=
local_scope
->
Var
(
var_desc
->
Name
())
->
GetMutable
<
LoDTensor
>
();
t
->
Resize
(
dims
);
for
(
size_t
i
=
0
;
i
<
member_
->
places_
.
size
();
++
i
)
{
auto
place
=
member_
->
places_
[
i
];
void
*
buffer
;
if
(
i
==
0
)
{
buffer
=
const_cast
<
void
*>
(
main_tensor
.
data
<
void
>
());
}
else
{
auto
local_scope
=
member_
->
local_scopes_
[
place
];
auto
*
t
=
local_scope
->
Var
(
var_desc
->
Name
())
->
GetMutable
<
LoDTensor
>
();
t
->
Resize
(
dims
);
buffer
=
t
->
mutable_data
(
place
,
main_tensor
.
type
());
}
auto
&
nccl_ctx
=
member_
->
GetNCCLCtx
(
place
);
platform
::
dynload
::
ncclBcast
(
t
->
mutable_data
(
place
,
main_tensor
.
type
()),
numel
,
data_type
,
0
,
nccl_ctx
.
comm
,
platform
::
dynload
::
ncclBcast
(
buffer
,
numel
,
data_type
,
0
,
nccl_ctx
.
comm
,
nccl_ctx
.
stream
());
}
platform
::
dynload
::
ncclGroupEnd
();
...
...
@@ -533,7 +541,7 @@ void ParallelExecutor::BuildNCCLCommunicator() const {
}
ParallelExecutorPrivate
::
NCCLContext
::
InitNCCLContext
(
member_
->
communication_streams_
);
member_
->
communication_streams_
,
member_
->
places_
);
#endif
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录