Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
612e1a31
P
Paddle
项目概览
机器未来
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
612e1a31
编写于
9月 15, 2018
作者:
S
sneaxiy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modification
上级
d0b2453e
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
24 addition
and
35 deletion
+24
-35
paddle/fluid/framework/details/computation_op_handle.h
paddle/fluid/framework/details/computation_op_handle.h
+0
-2
paddle/fluid/framework/details/op_handle_base.h
paddle/fluid/framework/details/op_handle_base.h
+0
-5
paddle/fluid/framework/details/reference_count_op_handle.h
paddle/fluid/framework/details/reference_count_op_handle.h
+5
-5
paddle/fluid/framework/details/reference_count_pass.cc
paddle/fluid/framework/details/reference_count_pass.cc
+3
-5
paddle/fluid/framework/executor.cc
paddle/fluid/framework/executor.cc
+8
-9
paddle/fluid/framework/executor.h
paddle/fluid/framework/executor.h
+0
-2
paddle/fluid/framework/parallel_executor.cc
paddle/fluid/framework/parallel_executor.cc
+0
-1
paddle/fluid/framework/parallel_executor.h
paddle/fluid/framework/parallel_executor.h
+4
-0
paddle/fluid/framework/scope.cc
paddle/fluid/framework/scope.cc
+3
-3
paddle/fluid/platform/device_context.h
paddle/fluid/platform/device_context.h
+0
-2
python/paddle/fluid/__init__.py
python/paddle/fluid/__init__.py
+1
-1
未找到文件。
paddle/fluid/framework/details/computation_op_handle.h
浏览文件 @
612e1a31
...
...
@@ -23,8 +23,6 @@
#include "paddle/fluid/framework/scope.h"
#include "paddle/fluid/platform/device_context.h"
#include "paddle/fluid/framework/details/reference_count_op_handle.h"
namespace
paddle
{
namespace
framework
{
namespace
details
{
...
...
paddle/fluid/framework/details/op_handle_base.h
浏览文件 @
612e1a31
...
...
@@ -89,11 +89,6 @@ class OpHandleBase {
ir
::
Node
*
Node
()
{
return
node_
;
}
const
std
::
map
<
platform
::
Place
,
platform
::
DeviceContext
*>
&
GetDeviceContexts
()
const
{
return
dev_ctxes_
;
}
protected:
void
RunAndRecordEvent
(
const
std
::
function
<
void
()
>
&
callback
);
...
...
paddle/fluid/framework/details/reference_count_op_handle.h
浏览文件 @
612e1a31
...
...
@@ -69,15 +69,15 @@ class ReferenceCountOpHandle : public OpHandleBase {
std
::
string
Name
()
const
override
{
return
"reference_count"
;
}
//
protected:
protected:
void
RunImpl
()
override
{
auto
*
exec_scope
_
=
scope_
->
FindVar
(
kLocalExecScopeName
)
->
Get
<
Scope
*>
();
auto
*
exec_scope
=
scope_
->
FindVar
(
kLocalExecScopeName
)
->
Get
<
Scope
*>
();
std
::
vector
<
LoDTensor
*>
tensors
;
for
(
auto
&
name
:
var_names_
)
{
auto
it
=
ref_cnts_
->
find
(
name
);
if
(
it
==
ref_cnts_
->
end
())
continue
;
auto
*
var
=
exec_scope
_
->
FindVar
(
name
);
auto
*
var
=
exec_scope
->
FindVar
(
name
);
if
(
var
==
nullptr
||
!
var
->
IsType
<
LoDTensor
>
())
continue
;
if
(
it
->
second
.
fetch_sub
(
1
)
<=
1
)
{
...
...
@@ -91,8 +91,8 @@ class ReferenceCountOpHandle : public OpHandleBase {
}
private:
void
ClearTensors
(
const
std
::
vector
<
LoDTensor
*>
&
tensors
)
const
{
auto
*
gc
=
dynamic_cast
<
const
StreamGarbageCollector
<
Tensor
>
*>
(
gc_
);
void
ClearTensors
(
const
std
::
vector
<
LoDTensor
*>
&
tensors
)
{
auto
*
gc
=
dynamic_cast
<
StreamGarbageCollector
<
Tensor
>
*>
(
gc_
);
if
(
gc
!=
nullptr
)
{
auto
compute_stream
=
dev_ctx_
->
stream
();
auto
callback_stream
=
gc
->
stream
();
...
...
paddle/fluid/framework/details/reference_count_pass.cc
浏览文件 @
612e1a31
...
...
@@ -128,12 +128,10 @@ std::unique_ptr<ir::Graph> ReferenceCountPass::ApplyImpl(
std
::
vector
<
std
::
unique_ptr
<
OpHandleBase
>>
new_all_ops
;
new_all_ops
.
reserve
(
compute_ref_cnt_map
.
size
()
+
all_ops
.
size
());
for
(
auto
&
op
:
all_ops
)
{
auto
it
=
compute_ref_cnt_map
.
find
(
op
.
get
());
new_all_ops
.
emplace_back
(
std
::
move
(
op
));
auto
it
=
compute_ref_cnt_map
.
find
(
new_all_ops
.
back
().
get
());
if
(
it
!=
compute_ref_cnt_map
.
end
())
{
new_all_ops
.
emplace_back
(
std
::
move
(
op
));
new_all_ops
.
emplace_back
(
std
::
unique_ptr
<
OpHandleBase
>
(
it
->
second
));
}
else
{
new_all_ops
.
emplace_back
(
std
::
move
(
op
));
new_all_ops
.
emplace_back
(
it
->
second
);
}
}
...
...
paddle/fluid/framework/executor.cc
浏览文件 @
612e1a31
...
...
@@ -37,9 +37,11 @@ int kProgramId = -1;
ExecutorPrepareContext
::
ExecutorPrepareContext
(
const
framework
::
ProgramDesc
&
prog
,
size_t
block_id
)
:
prog_
(
prog
),
block_id_
(
block_id
),
ref_cnts_
(
GetNonPersistableReferenceCount
<
int
>
(
prog
,
block_id
))
{}
:
prog_
(
prog
),
block_id_
(
block_id
)
{
if
(
GetEagerDeletionThreshold
()
>=
0
)
{
ref_cnts_
=
GetNonPersistableReferenceCount
<
int
>
(
prog_
,
block_id_
);
}
}
ExecutorPrepareContext
::~
ExecutorPrepareContext
()
{
VLOG
(
5
)
<<
"destroy ExecutorPrepareContext"
;
...
...
@@ -331,8 +333,6 @@ void Executor::RunPreparedContext(ExecutorPrepareContext* ctx, Scope* scope,
CreateVariables
(
ctx
->
prog_
,
local_scope
,
ctx
->
block_id_
);
}
std
::
shared_ptr
<
std
::
vector
<
framework
::
LoDTensor
*>>
erase_tensors
(
new
std
::
vector
<
framework
::
LoDTensor
*>
());
int64_t
max_memory_size
=
GetEagerDeletionThreshold
();
std
::
unique_ptr
<
GarbageCollector
<
Tensor
>>
gc
;
...
...
@@ -353,7 +353,6 @@ void Executor::RunPreparedContext(ExecutorPrepareContext* ctx, Scope* scope,
for
(
auto
&
op
:
ctx
->
ops_
)
{
op
->
Run
(
*
local_scope
,
place_
);
#ifdef PADDLE_WITH_CUDA
if
(
gc
!=
nullptr
)
{
std
::
vector
<
std
::
string
>
erase_vars
;
for
(
auto
&
input
:
op
->
Inputs
())
{
...
...
@@ -395,7 +394,6 @@ void Executor::RunPreparedContext(ExecutorPrepareContext* ctx, Scope* scope,
if
(
!
erase_tensors
.
empty
())
gc
->
Add
(
erase_tensors
);
}
}
#endif
if
(
FLAGS_benchmark
)
{
VLOG
(
2
)
<<
"Memory used after operator "
+
op
->
Type
()
+
" running: "
...
...
@@ -403,10 +401,11 @@ void Executor::RunPreparedContext(ExecutorPrepareContext* ctx, Scope* scope,
}
}
if
(
gc
!=
nullptr
)
if
(
gc
!=
nullptr
)
{
gc
->
Wait
();
else
}
else
{
platform
::
DeviceContextPool
::
Instance
().
Get
(
place_
)
->
Wait
();
}
if
(
local_scope
!=
scope
)
{
scope
->
DeleteScope
(
local_scope
);
...
...
paddle/fluid/framework/executor.h
浏览文件 @
612e1a31
...
...
@@ -28,8 +28,6 @@ namespace paddle {
namespace
framework
{
extern
void
InitializeVariable
(
Variable
*
var
,
proto
::
VarType
::
Type
var_type
);
int64_t
GetEagerDeletionThreshold
();
template
<
typename
T
>
std
::
unordered_map
<
std
::
string
,
T
>
GetNonPersistableReferenceCount
(
const
ProgramDesc
&
prog
,
size_t
block_id
)
{
...
...
paddle/fluid/framework/parallel_executor.cc
浏览文件 @
612e1a31
...
...
@@ -22,7 +22,6 @@ limitations under the License. */
#include "paddle/fluid/framework/ir/graph_viz_pass.h"
#ifdef PADDLE_WITH_CUDA
#include "paddle/fluid/framework/details/reference_count_pass.h"
#include "paddle/fluid/platform/nccl_helper.h"
#endif
...
...
paddle/fluid/framework/parallel_executor.h
浏览文件 @
612e1a31
...
...
@@ -29,6 +29,10 @@ limitations under the License. */
#include "paddle/fluid/framework/tensor.h"
#include "paddle/fluid/platform/device_context.h"
#ifdef PADDLE_WITH_CUDA
#include "paddle/fluid/framework/details/reference_count_pass.h"
#endif
namespace
paddle
{
namespace
framework
{
...
...
paddle/fluid/framework/scope.cc
浏览文件 @
612e1a31
...
...
@@ -32,7 +32,7 @@ DEFINE_bool(
"slow down the destruction of variables.(around 1% performance harm)"
);
DEFINE_double
(
eager_delete_tensor_
GB
,
-
1.0
,
eager_delete_tensor_
gb
,
-
1.0
,
"Memory size threshold (GB) when the garbage collector clear tensors."
"Disabled when this value is less than 0"
);
...
...
@@ -40,9 +40,9 @@ namespace paddle {
namespace
framework
{
int64_t
GetEagerDeletionThreshold
()
{
return
FLAGS_eager_delete_tensor_
GB
<
0
return
FLAGS_eager_delete_tensor_
gb
<
0
?
-
1
:
static_cast
<
int64_t
>
(
FLAGS_eager_delete_tensor_
GB
*
:
static_cast
<
int64_t
>
(
FLAGS_eager_delete_tensor_
gb
*
(
static_cast
<
int64_t
>
(
1
)
<<
30
));
}
...
...
paddle/fluid/platform/device_context.h
浏览文件 @
612e1a31
...
...
@@ -36,8 +36,6 @@ limitations under the License. */
#endif
#include "unsupported/Eigen/CXX11/Tensor"
DECLARE_bool
(
clear_gpu_memory_when_unused
);
namespace
paddle
{
namespace
platform
{
...
...
python/paddle/fluid/__init__.py
浏览文件 @
612e1a31
...
...
@@ -122,7 +122,7 @@ def __bootstrap__():
'use_pinned_memory'
,
'check_nan_inf'
,
'benchmark'
,
'warpctc_dir'
,
'eager_delete_scope'
,
'use_mkldnn'
,
'initial_cpu_memory_in_mb'
,
'init_allocated_mem'
,
'free_idle_memory'
,
'paddle_num_threads'
,
"dist_threadpool_size"
,
'cpu_deterministic'
,
'eager_delete_tensor_
GB
'
"dist_threadpool_size"
,
'cpu_deterministic'
,
'eager_delete_tensor_
gb
'
]
if
core
.
is_compiled_with_dist
():
read_env_flags
.
append
(
'rpc_deadline'
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录