From 1df354e7a96cdaf8363ac13a1d46c1f519daa826 Mon Sep 17 00:00:00 2001 From: Wilber Date: Fri, 31 Dec 2021 15:02:58 +0800 Subject: [PATCH] fix python ascend run error. (#38605) --- paddle/fluid/pybind/inference_api.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/paddle/fluid/pybind/inference_api.cc b/paddle/fluid/pybind/inference_api.cc index 5193724ece..5b788caeb1 100644 --- a/paddle/fluid/pybind/inference_api.cc +++ b/paddle/fluid/pybind/inference_api.cc @@ -742,7 +742,13 @@ void BindPaddleInferPredictor(py::module *m) { .def("get_output_names", &paddle_infer::Predictor::GetOutputNames) .def("get_input_handle", &paddle_infer::Predictor::GetInputHandle) .def("get_output_handle", &paddle_infer::Predictor::GetOutputHandle) - .def("run", &paddle_infer::Predictor::Run) + .def("run", + [](paddle_infer::Predictor &self) { +#ifdef PADDLE_WITH_ASCEND_CL + pybind11::gil_scoped_release release; +#endif + self.Run(); + }) .def("clone", &paddle_infer::Predictor::Clone) .def("try_shrink_memory", &paddle_infer::Predictor::TryShrinkMemory) .def("clear_intermediate_tensor", -- GitLab