Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
a8fff38f
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看板
未验证
提交
a8fff38f
编写于
2月 28, 2023
作者:
Y
Yuanle Liu
提交者:
GitHub
2月 28, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix gflags from environment not activated (#50864)
上级
75a2f9d5
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
28 addition
and
28 deletion
+28
-28
paddle/fluid/inference/api/analysis_config.cc
paddle/fluid/inference/api/analysis_config.cc
+7
-0
paddle/fluid/inference/api/analysis_predictor.cc
paddle/fluid/inference/api/analysis_predictor.cc
+0
-26
paddle/fluid/inference/api/helper.cc
paddle/fluid/inference/api/helper.cc
+18
-0
paddle/fluid/inference/api/helper.h
paddle/fluid/inference/api/helper.h
+2
-0
paddle/fluid/inference/api/paddle_analysis_config.h
paddle/fluid/inference/api/paddle_analysis_config.h
+1
-1
paddle/fluid/platform/init.cc
paddle/fluid/platform/init.cc
+0
-1
未找到文件。
paddle/fluid/inference/api/analysis_config.cc
浏览文件 @
a8fff38f
...
...
@@ -16,6 +16,7 @@
#include <string>
#include <tuple>
#include "paddle/fluid/inference/api/helper.h"
#include "paddle/fluid/inference/api/paddle_analysis_config.h"
#include "paddle/fluid/inference/api/paddle_pass_builder.h"
#include "paddle/fluid/inference/utils/table_printer.h"
...
...
@@ -40,6 +41,12 @@ extern const std::vector<std::string> kTRTSubgraphPasses;
extern
const
std
::
vector
<
std
::
string
>
kDlnneSubgraphPasses
;
extern
const
std
::
vector
<
std
::
string
>
kLiteSubgraphPasses
;
AnalysisConfig
::
AnalysisConfig
()
{
// NOTE(liuyuanle): Why put the following code here?
// ref to https://github.com/PaddlePaddle/Paddle/pull/50864
inference
::
InitGflagsFromEnv
();
}
PassStrategy
*
AnalysisConfig
::
pass_builder
()
const
{
if
(
!
pass_builder_
.
get
())
{
if
(
use_gpu_
)
{
...
...
paddle/fluid/inference/api/analysis_predictor.cc
浏览文件 @
a8fff38f
...
...
@@ -1497,32 +1497,6 @@ CreatePaddlePredictor<AnalysisConfig, PaddleEngineKind::kAnalysis>(
if
(
std
::
getenv
(
"FLAGS_initial_cpu_memory_in_mb"
)
==
nullptr
)
{
SetGflag
(
"initial_cpu_memory_in_mb"
,
"0"
);
}
// support set gflags from environment.
std
::
vector
<
std
::
string
>
gflags
;
const
phi
::
ExportedFlagInfoMap
&
env_map
=
phi
::
GetExportedFlagInfoMap
();
std
::
ostringstream
os
;
for
(
auto
&
pair
:
env_map
)
{
os
<<
pair
.
second
.
name
<<
","
;
}
std
::
string
tryfromenv_str
=
os
.
str
();
if
(
!
tryfromenv_str
.
empty
())
{
tryfromenv_str
.
pop_back
();
tryfromenv_str
=
"--tryfromenv="
+
tryfromenv_str
;
gflags
.
push_back
(
tryfromenv_str
);
}
if
(
framework
::
InitGflags
(
gflags
))
{
VLOG
(
3
)
<<
"The following gpu analysis configurations only take effect "
"for the first predictor: "
;
for
(
const
auto
&
gflag
:
gflags
)
{
VLOG
(
3
)
<<
gflag
;
}
}
else
{
LOG
(
WARNING
)
<<
"The one-time configuration of analysis predictor "
"failed, which may be due to native predictor called "
"first and its configurations taken effect."
;
}
});
if
(
config
.
thread_local_stream_enabled
()
&&
...
...
paddle/fluid/inference/api/helper.cc
浏览文件 @
a8fff38f
...
...
@@ -16,6 +16,7 @@
#include "paddle/fluid/framework/custom_operator.h"
#include "paddle/fluid/framework/operator.h"
#include "paddle/fluid/platform/init.h"
#include "paddle/phi/api/ext/op_meta_info.h"
namespace
paddle
{
...
...
@@ -59,5 +60,22 @@ void RegisterAllCustomOperator() {
}
}
void
InitGflagsFromEnv
()
{
// support set gflags from environment.
std
::
vector
<
std
::
string
>
gflags
;
const
phi
::
ExportedFlagInfoMap
&
env_map
=
phi
::
GetExportedFlagInfoMap
();
std
::
ostringstream
os
;
for
(
auto
&
pair
:
env_map
)
{
os
<<
pair
.
second
.
name
<<
","
;
}
std
::
string
tryfromenv_str
=
os
.
str
();
if
(
!
tryfromenv_str
.
empty
())
{
tryfromenv_str
.
pop_back
();
tryfromenv_str
=
"--tryfromenv="
+
tryfromenv_str
;
gflags
.
push_back
(
tryfromenv_str
);
}
framework
::
InitGflags
(
gflags
);
}
}
// namespace inference
}
// namespace paddle
paddle/fluid/inference/api/helper.h
浏览文件 @
a8fff38f
...
...
@@ -432,6 +432,8 @@ static bool IsFileExists(const std::string &path) {
void
RegisterAllCustomOperator
();
void
InitGflagsFromEnv
();
static
inline
double
ToMegaBytes
(
size_t
bytes
)
{
return
static_cast
<
double
>
(
bytes
)
/
(
1
<<
20
);
}
...
...
paddle/fluid/inference/api/paddle_analysis_config.h
浏览文件 @
a8fff38f
...
...
@@ -138,7 +138,7 @@ struct DistConfig {
/// and loading it into AnalysisPredictor.
///
struct
PD_INFER_DECL
AnalysisConfig
{
AnalysisConfig
()
=
default
;
AnalysisConfig
();
///
/// \brief Construct a new AnalysisConfig from another
/// AnalysisConfig.
...
...
paddle/fluid/platform/init.cc
浏览文件 @
a8fff38f
...
...
@@ -85,7 +85,6 @@ namespace framework {
std
::
once_flag
gflags_init_flag
;
std
::
once_flag
glog_init_flag
;
std
::
once_flag
npu_init_flag
;
std
::
once_flag
memory_method_init_flag
;
bool
InitGflags
(
std
::
vector
<
std
::
string
>
args
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录