Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
6e0cf610
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
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,发现更多精彩内容 >>
未验证
提交
6e0cf610
编写于
5月 23, 2023
作者:
T
Tian Zheng
提交者:
GitHub
5月 23, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix trt runtime destroy issue (#53937)
上级
01345a51
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
11 addition
and
10 deletion
+11
-10
paddle/fluid/inference/tensorrt/engine.cc
paddle/fluid/inference/tensorrt/engine.cc
+10
-10
paddle/fluid/inference/tensorrt/engine.h
paddle/fluid/inference/tensorrt/engine.h
+1
-0
未找到文件。
paddle/fluid/inference/tensorrt/engine.cc
浏览文件 @
6e0cf610
...
@@ -370,9 +370,9 @@ void TensorRTEngine::FreezeNetwork() {
...
@@ -370,9 +370,9 @@ void TensorRTEngine::FreezeNetwork() {
#else
#else
ihost_memory_
.
reset
(
infer_builder_
->
buildSerializedNetwork
(
ihost_memory_
.
reset
(
infer_builder_
->
buildSerializedNetwork
(
*
network
(),
*
infer_builder_config_
));
*
network
(),
*
infer_builder_config_
));
infer_
ptr
<
nvinfer1
::
IRuntime
>
runtime
(
createInferRuntime
(
&
logger_
));
infer_
runtime_
.
reset
(
createInferRuntime
(
&
logger_
));
infer_engine_
.
reset
(
runtime
->
deserializeCudaEngine
(
ihost_memory_
->
data
(),
infer_engine_
.
reset
(
infer_runtime_
->
deserializeCudaEngine
(
ihost_memory_
->
size
()));
ihost_memory_
->
data
(),
ihost_memory_
->
size
()));
#endif
#endif
PADDLE_ENFORCE_NOT_NULL
(
PADDLE_ENFORCE_NOT_NULL
(
...
@@ -559,31 +559,31 @@ std::unordered_map<std::string, nvinfer1::ITensor *>
...
@@ -559,31 +559,31 @@ std::unordered_map<std::string, nvinfer1::ITensor *>
void
TensorRTEngine
::
Deserialize
(
const
std
::
string
&
engine_serialized_data
)
{
void
TensorRTEngine
::
Deserialize
(
const
std
::
string
&
engine_serialized_data
)
{
freshDeviceId
();
freshDeviceId
();
infer_
ptr
<
nvinfer1
::
IRuntime
>
runtime
(
createInferRuntime
(
&
logger_
));
infer_
runtime_
.
reset
(
createInferRuntime
(
&
logger_
));
if
(
use_dla_
)
{
if
(
use_dla_
)
{
if
(
precision_
!=
phi
::
DataType
::
INT8
&&
if
(
precision_
!=
phi
::
DataType
::
INT8
&&
precision_
!=
phi
::
DataType
::
FLOAT16
)
{
precision_
!=
phi
::
DataType
::
FLOAT16
)
{
LOG
(
WARNING
)
<<
"TensorRT DLA must be used with int8 or fp16, but you "
LOG
(
WARNING
)
<<
"TensorRT DLA must be used with int8 or fp16, but you "
"set float32, so DLA is not used."
;
"set float32, so DLA is not used."
;
}
else
if
(
runtime
->
getNbDLACores
()
==
0
)
{
}
else
if
(
infer_runtime_
->
getNbDLACores
()
==
0
)
{
LOG
(
WARNING
)
LOG
(
WARNING
)
<<
"TensorRT DLA is set by config, but your device does not have "
<<
"TensorRT DLA is set by config, but your device does not have "
"DLA, so DLA is not used."
;
"DLA, so DLA is not used."
;
}
else
{
}
else
{
if
(
dla_core_
<
0
||
dla_core_
>=
runtime
->
getNbDLACores
())
{
if
(
dla_core_
<
0
||
dla_core_
>=
infer_runtime_
->
getNbDLACores
())
{
dla_core_
=
0
;
dla_core_
=
0
;
LOG
(
WARNING
)
<<
"Invalid DLACore, must be 0 < DLACore < "
LOG
(
WARNING
)
<<
"Invalid DLACore, must be 0 < DLACore < "
<<
runtime
->
getNbDLACores
()
<<
", but got "
<<
dla_core_
<<
infer_runtime_
->
getNbDLACores
()
<<
", but got "
<<
", so use use 0 as default."
;
<<
dla_core_
<<
", so use use 0 as default."
;
}
}
runtime
->
setDLACore
(
dla_core_
);
infer_runtime_
->
setDLACore
(
dla_core_
);
LOG
(
INFO
)
<<
"TensorRT DLA enabled in Deserialize(), DLACore "
LOG
(
INFO
)
<<
"TensorRT DLA enabled in Deserialize(), DLACore "
<<
dla_core_
;
<<
dla_core_
;
}
}
}
}
infer_engine_
.
reset
(
runtime
->
deserializeCudaEngine
(
infer_engine_
.
reset
(
infer_runtime_
->
deserializeCudaEngine
(
engine_serialized_data
.
c_str
(),
engine_serialized_data
.
size
()));
engine_serialized_data
.
c_str
(),
engine_serialized_data
.
size
()));
PADDLE_ENFORCE_NOT_NULL
(
PADDLE_ENFORCE_NOT_NULL
(
...
...
paddle/fluid/inference/tensorrt/engine.h
浏览文件 @
6e0cf610
...
@@ -811,6 +811,7 @@ class TensorRTEngine {
...
@@ -811,6 +811,7 @@ class TensorRTEngine {
// TensorRT related internal members
// TensorRT related internal members
infer_ptr
<
nvinfer1
::
IBuilder
>
infer_builder_
;
infer_ptr
<
nvinfer1
::
IBuilder
>
infer_builder_
;
infer_ptr
<
nvinfer1
::
INetworkDefinition
>
infer_network_
;
infer_ptr
<
nvinfer1
::
INetworkDefinition
>
infer_network_
;
infer_ptr
<
nvinfer1
::
IRuntime
>
infer_runtime_
;
infer_ptr
<
nvinfer1
::
ICudaEngine
>
infer_engine_
;
infer_ptr
<
nvinfer1
::
ICudaEngine
>
infer_engine_
;
std
::
unordered_map
<
PredictorID
,
infer_ptr
<
nvinfer1
::
IExecutionContext
>>
std
::
unordered_map
<
PredictorID
,
infer_ptr
<
nvinfer1
::
IExecutionContext
>>
infer_context_
;
infer_context_
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录