Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
0ef9edf5
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
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看板
提交
0ef9edf5
编写于
3月 16, 2018
作者:
Y
Yu Yang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Stash
上级
5e87cd75
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
27 addition
and
18 deletion
+27
-18
paddle/fluid/framework/parallel_executor.cc
paddle/fluid/framework/parallel_executor.cc
+26
-17
python/paddle/fluid/tests/unittests/test_parallel_executor.py
...on/paddle/fluid/tests/unittests/test_parallel_executor.py
+1
-1
未找到文件。
paddle/fluid/framework/parallel_executor.cc
浏览文件 @
0ef9edf5
...
@@ -229,8 +229,15 @@ class ParallelExecutorPrivate {
...
@@ -229,8 +229,15 @@ class ParallelExecutorPrivate {
// TODO(yy): Move this function somewhere
// TODO(yy): Move this function somewhere
ncclDataType_t
ToNCCLDataType
(
std
::
type_index
type
)
{
ncclDataType_t
ToNCCLDataType
(
std
::
type_index
type
)
{
// FIXME!!
if
(
type
==
typeid
(
float
))
{
// NOLINT
return
ncclFloat
;
return
ncclFloat
;
}
else
if
(
type
==
typeid
(
double
))
{
// NOLINT
return
ncclDouble
;
}
else
if
(
type
==
typeid
(
int
))
{
// NOLINT
return
ncclInt
;
}
else
{
PADDLE_THROW
(
"Not supported"
);
}
}
}
ParallelExecutor
::
ParallelExecutor
(
ParallelExecutor
::
ParallelExecutor
(
...
@@ -479,30 +486,32 @@ void ParallelExecutor::BCastParamsToGPUs(
...
@@ -479,30 +486,32 @@ void ParallelExecutor::BCastParamsToGPUs(
ncclDataType_t
data_type
=
ToNCCLDataType
(
main_tensor
.
type
());
ncclDataType_t
data_type
=
ToNCCLDataType
(
main_tensor
.
type
());
auto
&
dims
=
main_tensor
.
dims
();
auto
&
dims
=
main_tensor
.
dims
();
size_t
numel
=
main_tensor
.
numel
();
size_t
numel
=
main_tensor
.
numel
();
std
::
vector
<
std
::
pair
<
void
*
,
ParallelExecutorPrivate
::
NCCLContext
*>>
mems
;
mems
.
emplace_back
(
const_cast
<
void
*>
(
main_tensor
.
data
<
void
>
()),
&
member_
->
GetNCCLCtx
(
member_
->
main_place_
));
for
(
auto
&
pair
:
member_
->
local_scopes_
)
{
platform
::
dynload
::
ncclGroupStart
();
if
(
pair
.
first
==
member_
->
main_place_
)
{
continue
;
}
for
(
auto
&
pair
:
member_
->
local_scopes_
)
{
auto
local_scope
=
pair
.
second
;
auto
local_scope
=
pair
.
second
;
auto
*
t
=
local_scope
->
Var
(
var_desc
->
Name
())
->
GetMutable
<
LoDTensor
>
();
auto
*
t
=
local_scope
->
Var
(
var_desc
->
Name
())
->
GetMutable
<
LoDTensor
>
();
t
->
Resize
(
dims
);
t
->
Resize
(
dims
);
mems
.
emplace_back
(
t
->
mutable_data
(
pair
.
first
,
main_tensor
.
type
()),
auto
&
nccl_ctx
=
member_
->
GetNCCLCtx
(
pair
.
first
);
&
member_
->
GetNCCLCtx
(
member_
->
main_place_
));
platform
::
dynload
::
ncclBcast
(
t
->
mutable_data
(
pair
.
first
,
main_tensor
.
type
()),
numel
,
data_type
,
0
,
nccl_ctx
.
comm
,
nccl_ctx
.
stream
());
}
platform
::
dynload
::
ncclGroupEnd
();
}
}
}
// TODO(yy): Invoke ncclBCast here. mems, numel, data_type. The mems[0]
for
(
auto
&
pair
:
member_
->
local_scopes_
)
{
// is the src, rests are dests.
member_
->
GetNCCLCtx
(
pair
.
first
).
ctx_
->
Wait
();
(
void
)(
data_type
);
auto
&
b
=
pair
.
second
->
FindVar
(
"fc_1.b_0"
)
->
Get
<
framework
::
LoDTensor
>
();
(
void
)(
numel
);
framework
::
LoDTensor
cpu
;
}
framework
::
TensorCopy
(
b
,
platform
::
CPUPlace
(),
&
cpu
);
platform
::
DeviceContextPool
::
Instance
().
Get
(
b
.
place
())
->
Wait
();
LOG
(
INFO
)
<<
*
cpu
.
data
<
float
>
();
}
}
#else
#else
PADDLE_THROW
(
"Not compiled with CUDA"
);
PADDLE_THROW
(
"Not compiled with CUDA"
);
#endif
#endif
...
...
python/paddle/fluid/tests/unittests/test_parallel_executor.py
浏览文件 @
0ef9edf5
...
@@ -52,7 +52,7 @@ class ParallelExecutor(unittest.TestCase):
...
@@ -52,7 +52,7 @@ class ParallelExecutor(unittest.TestCase):
adam
=
fluid
.
optimizer
.
Adam
()
adam
=
fluid
.
optimizer
.
Adam
()
adam
.
minimize
(
loss
)
adam
.
minimize
(
loss
)
act_places
=
[]
act_places
=
[]
for
each
in
[
fluid
.
CUDAPlace
(
0
)]:
for
each
in
[
fluid
.
CUDAPlace
(
0
)
,
fluid
.
CUDAPlace
(
1
)
]:
p
=
fluid
.
core
.
Place
()
p
=
fluid
.
core
.
Place
()
p
.
set_place
(
each
)
p
.
set_place
(
each
)
act_places
.
append
(
p
)
act_places
.
append
(
p
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录