Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
b138d29c
P
Paddle
项目概览
PaddlePaddle
/
Paddle
12 个月 前同步成功
通知
2292
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,发现更多精彩内容 >>
提交
b138d29c
编写于
4月 06, 2018
作者:
X
Xin Pan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Avoid init_p2p all the times
上级
09b4a1a3
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
23 addition
and
15 deletion
+23
-15
paddle/fluid/framework/data_device_transform_test.cu
paddle/fluid/framework/data_device_transform_test.cu
+1
-1
paddle/fluid/framework/init.cc
paddle/fluid/framework/init.cc
+4
-2
paddle/fluid/framework/init.h
paddle/fluid/framework/init.h
+1
-1
paddle/fluid/framework/init_test.cc
paddle/fluid/framework/init_test.cc
+2
-2
paddle/fluid/framework/lod_tensor_test.cu
paddle/fluid/framework/lod_tensor_test.cu
+2
-2
paddle/fluid/framework/operator_test.cc
paddle/fluid/framework/operator_test.cc
+4
-4
paddle/fluid/pybind/pybind.cc
paddle/fluid/pybind/pybind.cc
+2
-1
paddle/testing/paddle_gtest_main.cc
paddle/testing/paddle_gtest_main.cc
+1
-1
python/paddle/fluid/__init__.py
python/paddle/fluid/__init__.py
+6
-1
未找到文件。
paddle/fluid/framework/data_device_transform_test.cu
浏览文件 @
b138d29c
...
...
@@ -105,7 +105,7 @@ static void BuildVar(const std::string& param_name,
TEST
(
Operator
,
CPUtoGPU
)
{
using
namespace
paddle
::
framework
;
using
namespace
paddle
::
platform
;
InitDevices
();
InitDevices
(
true
);
paddle
::
framework
::
Scope
scope
;
paddle
::
platform
::
CPUPlace
cpu_place
;
...
...
paddle/fluid/framework/init.cc
浏览文件 @
b138d29c
...
...
@@ -64,7 +64,7 @@ void InitP2P(int count) {
#endif
}
void
InitDevices
()
{
void
InitDevices
(
bool
init_p2p
)
{
/*Init all avaiable devices by default */
std
::
vector
<
platform
::
Place
>
places
;
...
...
@@ -85,7 +85,9 @@ void InitDevices() {
for
(
int
i
=
0
;
i
<
count
;
++
i
)
{
places
.
emplace_back
(
platform
::
CUDAPlace
(
i
));
}
InitP2P
(
count
);
if
(
init_p2p
)
{
InitP2P
(
count
);
}
platform
::
DeviceContextPool
::
Init
(
places
);
}
...
...
paddle/fluid/framework/init.h
浏览文件 @
b138d29c
...
...
@@ -24,7 +24,7 @@ void InitGflags(std::vector<std::string> &argv);
void
InitGLOG
(
const
std
::
string
&
prog_name
);
void
InitDevices
();
void
InitDevices
(
bool
init_p2p
);
}
// namespace framework
}
// namespace paddle
paddle/fluid/framework/init_test.cc
浏览文件 @
b138d29c
...
...
@@ -21,7 +21,7 @@ TEST(InitDevices, CPU) {
using
paddle
::
platform
::
DeviceContextPool
;
#ifndef PADDLE_WITH_CUDA
InitDevices
();
InitDevices
(
true
);
DeviceContextPool
&
pool
=
DeviceContextPool
::
Instance
();
ASSERT_EQ
(
pool
.
size
(),
1U
);
#endif
...
...
@@ -33,7 +33,7 @@ TEST(InitDevices, CUDA) {
#ifdef PADDLE_WITH_CUDA
int
count
=
paddle
::
platform
::
GetCUDADeviceCount
();
InitDevices
();
InitDevices
(
true
);
DeviceContextPool
&
pool
=
DeviceContextPool
::
Instance
();
ASSERT_EQ
(
pool
.
size
(),
1U
+
static_cast
<
unsigned
>
(
count
));
#endif
...
...
paddle/fluid/framework/lod_tensor_test.cu
浏览文件 @
b138d29c
...
...
@@ -30,7 +30,7 @@ __global__ void test(size_t* a, int size) {
}
TEST
(
LoD
,
data
)
{
paddle
::
framework
::
InitDevices
();
paddle
::
framework
::
InitDevices
(
true
);
paddle
::
framework
::
LoD
lod
{{
0
,
1
,
2
}};
lod
.
push_back
({
0
,
2
,
4
,
5
});
...
...
@@ -46,7 +46,7 @@ TEST(LoD, data) {
}
TEST
(
LoDTensor
,
LoDInGPU
)
{
paddle
::
framework
::
InitDevices
();
paddle
::
framework
::
InitDevices
(
true
);
paddle
::
framework
::
LoDTensor
lod_tensor
;
paddle
::
platform
::
CUDAPlace
place
(
0
);
...
...
paddle/fluid/framework/operator_test.cc
浏览文件 @
b138d29c
...
...
@@ -72,7 +72,7 @@ REGISTER_OP_WITHOUT_GRADIENT(test_operator,
paddle
::
framework
::
OpWithoutKernelCheckerMaker
);
TEST
(
OperatorBase
,
all
)
{
paddle
::
framework
::
InitDevices
();
paddle
::
framework
::
InitDevices
(
true
);
paddle
::
framework
::
proto
::
OpDesc
op_desc
;
op_desc
.
set_type
(
"test_operator"
);
BuildVar
(
"input"
,
{
"IN1"
},
op_desc
.
add_inputs
());
...
...
@@ -198,7 +198,7 @@ REGISTER_OP_CPU_KERNEL(op_with_kernel,
// test with single input
TEST
(
OpKernel
,
all
)
{
paddle
::
framework
::
InitDevices
();
paddle
::
framework
::
InitDevices
(
true
);
paddle
::
framework
::
proto
::
OpDesc
op_desc
;
op_desc
.
set_type
(
"op_with_kernel"
);
BuildVar
(
"x"
,
{
"IN1"
},
op_desc
.
add_inputs
());
...
...
@@ -228,7 +228,7 @@ REGISTER_OP_CPU_KERNEL(op_multi_inputs_with_kernel,
TEST
(
OpKernel
,
multi_inputs
)
{
using
namespace
paddle
::
framework
;
paddle
::
framework
::
InitDevices
();
paddle
::
framework
::
InitDevices
(
true
);
proto
::
OpDesc
op_desc
;
op_desc
.
set_type
(
"op_multi_inputs_with_kernel"
);
...
...
@@ -269,7 +269,7 @@ class OperatorClone : public paddle::framework::OperatorBase {
};
TEST
(
Operator
,
Clone
)
{
paddle
::
framework
::
InitDevices
();
paddle
::
framework
::
InitDevices
(
true
);
OperatorClone
a
(
"ABC"
,
paddle
::
framework
::
VariableNameMap
{},
paddle
::
framework
::
VariableNameMap
{},
paddle
::
framework
::
AttributeMap
{});
...
...
paddle/fluid/pybind/pybind.cc
浏览文件 @
b138d29c
...
...
@@ -423,7 +423,8 @@ All parameter, weight, gradient are variables in Paddle.
m
.
def
(
"init_gflags"
,
framework
::
InitGflags
);
m
.
def
(
"init_glog"
,
framework
::
InitGLOG
);
m
.
def
(
"init_devices"
,
&
framework
::
InitDevices
);
m
.
def
(
"init_devices"
,
[](
bool
init_p2p
)
{
framework
::
InitDevices
(
init_p2p
);
});
m
.
def
(
"is_compiled_with_cuda"
,
IsCompiledWithCUDA
);
#ifdef PADDLE_WITH_CUDA
...
...
paddle/testing/paddle_gtest_main.cc
浏览文件 @
b138d29c
...
...
@@ -41,6 +41,6 @@ int main(int argc, char** argv) {
paddle
::
memory
::
Used
(
paddle
::
platform
::
CUDAPlace
(
0
));
#endif
paddle
::
framework
::
InitDevices
();
paddle
::
framework
::
InitDevices
(
true
);
return
RUN_ALL_TESTS
();
}
python/paddle/fluid/__init__.py
浏览文件 @
b138d29c
...
...
@@ -84,6 +84,8 @@ def __bootstrap__():
import
core
import
os
in_test
=
'unittest'
in
sys
.
modules
try
:
num_threads
=
int
(
os
.
getenv
(
'OMP_NUM_THREADS'
,
'1'
))
except
ValueError
:
...
...
@@ -108,8 +110,11 @@ def __bootstrap__():
core
.
init_gflags
([
sys
.
argv
[
0
]]
+
[
"--tryfromenv="
+
","
.
join
(
read_env_flags
)])
core
.
init_glog
(
sys
.
argv
[
0
])
core
.
init_devices
()
# don't init_p2p when in unittest to save time.
core
.
init_devices
(
not
in_test
)
# TODO(panyx0718): Avoid doing complex initialization logic in __init__.py.
# Consider paddle.init(args) or paddle.main(args)
layers
.
monkey_patch_variable
()
__bootstrap__
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录