Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
1e8474b9
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
大约 1 年 前同步成功
通知
694
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1e8474b9
编写于
10月 24, 2017
作者:
D
Dong Zhihong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
"delete python ops testcase"
上级
0990c87b
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
29 addition
and
118 deletion
+29
-118
paddle/operators/nccl_op_test.cu
paddle/operators/nccl_op_test.cu
+29
-23
python/paddle/v2/framework/tests/test_multigpu.py
python/paddle/v2/framework/tests/test_multigpu.py
+0
-8
python/paddle/v2/framework/tests/test_nccl_ops.py
python/paddle/v2/framework/tests/test_nccl_ops.py
+0
-87
未找到文件。
paddle/operators/nccl_op_test.cu
浏览文件 @
1e8474b9
...
...
@@ -13,8 +13,11 @@
limitations under the License. */
#include "paddle/operators/nccl_op.h"
#include "glog/logging.h"
#include "gtest/gtest.h"
#include <glog/logging.h>
#include <gtest/gtest.h>
#include <thrust/device_vector.h>
#include <memory>
#include <vector>
#include "paddle/framework/block_desc.h"
#include "paddle/framework/op_desc.h"
...
...
@@ -24,10 +27,13 @@
#include "paddle/platform/device_context.h"
#include "paddle/platform/enforce.h"
#include "paddle/platform/gpu_info.h"
#include "paddle/platform/place.h"
#include <thrust/device_vector.h>
#include <memory>
#include <vector>
USE_CPU_ONLY_OP
(
ncclInit
);
USE_GPU_ONLY_OP
(
ncclAllReduce
);
USE_GPU_ONLY_OP
(
ncclReduce
);
USE_GPU_ONLY_OP
(
ncclBcastSend
);
USE_GPU_ONLY_OP
(
ncclBcastRecv
);
static
std
::
vector
<
int
>
gpu_list
;
...
...
@@ -55,28 +61,28 @@ void AddOp(const std::string &type, const f::VariableNameMap &inputs,
op
->
SetAttrMap
(
attrs
);
}
TEST
(
NCCL
,
ncclInit
)
{
// ncclInitOp with desc
TEST
(
NCCL
,
ncclInitOp
)
{
f
::
ProgramDescBind
program
;
f
::
BlockDescBind
*
block
=
program
.
Block
(
0
);
f
::
OpDescBind
*
op
=
block
->
AppendOp
();
paddle
::
platform
::
Communicator
comm
;
op
->
SetType
(
"ncclInit"
);
op
->
SetOutput
(
"Communicator"
,
)
AddOp
(
"ncclInit"
,
{},
{{
"Communicator"
,
{
comm
}}},
{{
"gpus"
,
{
gpu_list
}}},
block
);
f
::
OpDescBind
*
op1
=
block
->
AppendOp
();
op1
->
SetType
(
"ncclInit"
);
op1
->
SetOutput
(
"Communicator"
,
{
"x1"
});
op1
->
SetAttr
(
"gpus"
,
{
gpu_list
});
f
::
Scope
g_scope
;
paddle
::
platform
::
DeviceContext
*
ctx
=
new
paddle
::
platform
::
CPUDeviceContext
(
paddle
::
platform
::
CPUPlace
());
auto
*
var
=
g_scope
.
Var
(
"x1"
);
var
->
GetMutable
<
paddle
::
platform
::
Communicator
>
();
auto
op
=
f
::
OpRegistry
::
CreateOp
(
*
op1
);
VLOG
(
1
)
<<
"invoke NCCLInitOp."
;
op
->
Run
(
g_scope
,
*
ctx
);
VLOG
(
1
)
<<
"NCCLInitOp finished."
;
}
// TEST(NCCL, ncclAllReduce) {
// f::ProgramDescBind program;
// f::BlockDescBind *block = program.Block(0);
// paddle::platform::Communicator comm;
// AddOp("ncclInit", {}, {{"Communicator", {comm}}, {"gpus", {gpu_list}}},
// block);
// }
int
main
(
int
argc
,
char
**
argv
)
{
static
int
dev_count
=
paddle
::
platform
::
GetCUDADeviceCount
();
if
(
dev_count
<=
1
)
{
...
...
python/paddle/v2/framework/tests/test_multigpu.py
已删除
100644 → 0
浏览文件 @
0990c87b
import
unittest
,
os
import
numpy
as
np
import
paddle.v2
as
paddle
from
paddle.v2.framework.op
import
Operator
import
paddle.v2.framework.core
as
core
from
op_test
import
OpTest
,
create_op
,
set_input
gpu_list
=
"0,1,2,3"
python/paddle/v2/framework/tests/test_nccl_ops.py
已删除
100644 → 0
浏览文件 @
0990c87b
import
unittest
,
os
import
numpy
as
np
import
paddle.v2
as
paddle
from
paddle.v2.framework.op
import
Operator
import
paddle.v2.framework.core
as
core
from
op_test
import
OpTest
,
create_op
,
set_input
# gpu_list = os.environ["NV_LIST"]
gpu_list
=
"0,1,2,3"
if
not
core
.
is_compile_gpu
()
or
not
gpu_list
:
exit
(
0
)
def
allreduce
(
tensors
,
gpus
):
num_device
=
len
(
gpus
)
assert
(
len
(
tensors
)
==
num_device
),
"not match of tensor and device"
Out
=
tensors
for
i
in
range
(
1
,
len
(
tensors
)):
Out
[
0
]
+=
Out
[
i
]
for
i
in
range
(
1
,
len
(
tensors
)):
Out
[
i
]
=
Out
[
0
]
return
Out
class
TestNCCLAllReduce
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
op_type
=
"ncclAllReduce"
self
.
gpus
=
[
int
(
g
)
for
g
in
gpu_list
.
split
(
","
)]
self
.
g_scope
=
core
.
Scope
()
self
.
g_ctx
=
core
.
DeviceContext
.
create
(
core
.
CPUPlace
())
self
.
scopes
=
[]
self
.
ops
=
[]
self
.
places
=
[]
self
.
input_data
=
[]
for
i
in
range
(
len
(
self
.
gpus
)):
self
.
input_data
.
append
(
np
.
random
.
random
((
32
,
32
)))
self
.
output_data
=
allreduce
(
self
.
input_data
,
self
.
gpus
)
nccl_init
=
Operator
(
"ncclInit"
,
Out
=
"Communicator"
,
gpus
=
self
.
gpus
)
op
.
run
(
self
.
g_scope
,
self
.
g_ctx
)
for
i
in
range
(
len
(
self
.
gpus
)):
# insert kid scope
scope
=
self
.
g_scope
.
new_scope
()
place
=
core
.
GPUPlace
(
self
.
gpus
[
i
])
inputs
=
{
"X"
:
self
.
input_data
[
i
]}
outputs
=
{
"Out"
:
self
.
output_data
[
i
]}
attrs
=
{
"gpus"
:
self
.
gpus
}
op
=
create_op
(
scope
,
self
.
op_type
,
inputs
,
outputs
,
attrs
)
set_input
(
scope
,
op
,
inputs
,
place
)
self
.
scopes
.
append
(
scope
)
self
.
ops
.
append
(
op
)
self
.
places
.
append
(
place
)
def
test_output
(
self
):
idx
=
0
for
scope
,
place
,
op
in
zip
(
self
.
scopes
,
self
.
places
,
self
.
ops
):
ctx
=
core
.
DeviceContext
.
create
(
place
)
op
.
run
(
scope
,
ctx
)
for
out_name
,
out_dup
in
Operator
.
get_op_outputs
(
self
.
op
.
type
()):
actual
=
np
.
array
(
scope
.
find_var
(
out_name
).
get_tensor
())
expect
=
self
.
output_data
[
idx
]
idx
+=
1
self
.
assertTrue
(
actual
,
expect
),
"has diff"
# if __name__ == "__main__":
# unittest.main()
# usage : export NV_LIST=0,1,2,3 python *.py
# os.environ["NV_LIST"] = ["0,1,2,3"]
if
__name__
==
"__main__"
:
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录