未验证 提交 656124da 编写于 作者: W Wilber 提交者: GitHub

cherry-pick pr (#31043)

上级 25ee1a73
...@@ -631,6 +631,13 @@ std::unique_ptr<PaddlePredictor> CreatePaddlePredictor< ...@@ -631,6 +631,13 @@ std::unique_ptr<PaddlePredictor> CreatePaddlePredictor<
process_level_allocator_enabled = true; process_level_allocator_enabled = true;
} }
// TODO(wilber): jetson tx2 may fail to run the model due to insufficient memory
// under the native_best_fit strategy. Modify the default allocation strategy to
// auto_growth. todo, find a more appropriate way to solve the problem.
#ifdef WITH_NV_JETSON
gflags.push_back("--allocator_strategy=auto_growth");
#endif
if (framework::InitGflags(gflags)) { if (framework::InitGflags(gflags)) {
VLOG(3) << "The following gpu analysis configurations only take effect " VLOG(3) << "The following gpu analysis configurations only take effect "
"for the first predictor: "; "for the first predictor: ";
......
...@@ -95,9 +95,13 @@ const std::vector<std::string> kTRTSubgraphPasses({ ...@@ -95,9 +95,13 @@ const std::vector<std::string> kTRTSubgraphPasses({
"conv_bn_fuse_pass", // "conv_bn_fuse_pass", //
#if CUDNN_VERSION >= 7100 // To run conv_fusion, the version of cudnn must be #if CUDNN_VERSION >= 7100 // To run conv_fusion, the version of cudnn must be
// guaranteed at least v7 // guaranteed at least v7
// cudnn8.0 has memory leak problem in conv + eltwise + act, so we
// disable the pass.
#if !(CUDNN_VERSION >= 8000 && CUDNN_VERSION < 8100)
"conv_elementwise_add_act_fuse_pass", // "conv_elementwise_add_act_fuse_pass", //
"conv_elementwise_add2_act_fuse_pass", // "conv_elementwise_add2_act_fuse_pass", //
#endif // #endif
#endif
"transpose_flatten_concat_fuse_pass", "transpose_flatten_concat_fuse_pass",
}); });
......
...@@ -81,10 +81,35 @@ nvinfer1::Dims Vec2TRT_Dims(const std::vector<T>& shape, std::string input, ...@@ -81,10 +81,35 @@ nvinfer1::Dims Vec2TRT_Dims(const std::vector<T>& shape, std::string input,
"TensorRT's tensor input requires at most 4 " "TensorRT's tensor input requires at most 4 "
"dimensions, but input %s has %d dims.", "dimensions, but input %s has %d dims.",
input, shape.size())); input, shape.size()));
auto ShapeStr = [](const std::vector<T>& shape) {
std::ostringstream os;
os << "[";
for (size_t i = 0; i < shape.size(); ++i) {
if (i == shape.size() - 1) {
os << shape[i];
} else {
os << shape[i] << ",";
}
}
os << "]";
return os.str();
};
if (!with_dynamic_shape) { if (!with_dynamic_shape) {
if (shape.size() == 4UL) { if (shape.size() == 4UL) {
if (shape[2] == -1 || shape[3] == -1) {
PADDLE_THROW(platform::errors::InvalidArgument(
"The input [%s] shape of trt subgraph is %s, please enable "
"trt dynamic_shape mode by SetTRTDynamicShapeInfo.",
input, ShapeStr(shape)));
}
return nvinfer1::DimsCHW(shape[1], shape[2], shape[3]); return nvinfer1::DimsCHW(shape[1], shape[2], shape[3]);
} else if (shape.size() == 3UL) { } else if (shape.size() == 3UL) {
if (shape[1] == -1 || shape[2] == -1) {
PADDLE_THROW(platform::errors::InvalidArgument(
"The input [%s] shape of trt subgraph is %s, please enable "
"trt dynamic_shape mode by SetTRTDynamicShapeInfo.",
input, ShapeStr(shape)));
}
return nvinfer1::Dims2(shape[1], shape[2]); return nvinfer1::Dims2(shape[1], shape[2]);
} }
return nvinfer1::DimsCHW(shape[1], 1, 1); return nvinfer1::DimsCHW(shape[1], 1, 1);
......
...@@ -534,7 +534,10 @@ void BindAnalysisConfig(py::module *m) { ...@@ -534,7 +534,10 @@ void BindAnalysisConfig(py::module *m) {
[](AnalysisConfig &self, const std::string &pass) { [](AnalysisConfig &self, const std::string &pass) {
self.pass_builder()->DeletePass(pass); self.pass_builder()->DeletePass(pass);
}) })
.def("pass_builder", &AnalysisConfig::pass_builder, .def("pass_builder",
[](AnalysisConfig &self) {
return dynamic_cast<PaddlePassBuilder *>(self.pass_builder());
},
py::return_value_policy::reference); py::return_value_policy::reference);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册