| @@ -42,7 +42,10 @@ void PyMaster::StartRestfulServer(const std::string &ip, uint32_t grpc_port, int | |||||
| } | } | ||||
| void PyMaster::WaitAndClear() { | void PyMaster::WaitAndClear() { | ||||
| ExitHandle::Instance().MasterWait(); | |||||
| { | |||||
| py::gil_scoped_release release; | |||||
| ExitHandle::Instance().MasterWait(); | |||||
| } | |||||
| Server::Instance().Clear(); | Server::Instance().Clear(); | ||||
| MSI_LOG_INFO << "Python server end wait and clear"; | MSI_LOG_INFO << "Python server end wait and clear"; | ||||
| } | } | ||||
| @@ -108,7 +108,7 @@ PYBIND11_MODULE(_mindspore_serving, m) { | |||||
| .def_static("start_servable", &PyWorker::StartServable) | .def_static("start_servable", &PyWorker::StartServable) | ||||
| .def_static("start_servable_in_master", &PyWorker::StartServableInMaster) | .def_static("start_servable_in_master", &PyWorker::StartServableInMaster) | ||||
| .def_static("get_batch_size", &PyWorker::GetBatchSize) | .def_static("get_batch_size", &PyWorker::GetBatchSize) | ||||
| .def_static("wait_and_clear", &PyWorker::WaitAndClear, py::call_guard<py::gil_scoped_release>()) | |||||
| .def_static("wait_and_clear", &PyWorker::WaitAndClear) | |||||
| .def_static("stop", PyWorker::Stop) | .def_static("stop", PyWorker::Stop) | ||||
| .def_static("get_py_task", &PyWorker::GetPyTask, py::call_guard<py::gil_scoped_release>()) | .def_static("get_py_task", &PyWorker::GetPyTask, py::call_guard<py::gil_scoped_release>()) | ||||
| .def_static("try_get_preprocess_py_task", &PyWorker::TryGetPreprocessPyTask) | .def_static("try_get_preprocess_py_task", &PyWorker::TryGetPreprocessPyTask) | ||||
| @@ -134,7 +134,7 @@ PYBIND11_MODULE(_mindspore_serving, m) { | |||||
| .def_static("start_grpc_server", &PyMaster::StartGrpcServer) | .def_static("start_grpc_server", &PyMaster::StartGrpcServer) | ||||
| .def_static("start_grpc_master_server", &PyMaster::StartGrpcMasterServer) | .def_static("start_grpc_master_server", &PyMaster::StartGrpcMasterServer) | ||||
| .def_static("start_restful_server", &PyMaster::StartRestfulServer) | .def_static("start_restful_server", &PyMaster::StartRestfulServer) | ||||
| .def_static("wait_and_clear", &PyMaster::WaitAndClear, py::call_guard<py::gil_scoped_release>()) | |||||
| .def_static("wait_and_clear", &PyMaster::WaitAndClear) | |||||
| .def_static("stop", &PyMaster::Stop); | .def_static("stop", &PyMaster::Stop); | ||||
| (void)py::module::import("atexit").attr("register")(py::cpp_function{[&]() -> void { | (void)py::module::import("atexit").attr("register")(py::cpp_function{[&]() -> void { | ||||
| @@ -118,7 +118,10 @@ void PyWorker::PushPostprocessPyFailed(int count) { | |||||
| } | } | ||||
| void PyWorker::WaitAndClear() { | void PyWorker::WaitAndClear() { | ||||
| ExitHandle::Instance().WorkerWait(); | |||||
| { | |||||
| py::gil_scoped_release release; | |||||
| ExitHandle::Instance().WorkerWait(); | |||||
| } | |||||
| Worker::GetInstance().Clear(); | Worker::GetInstance().Clear(); | ||||
| } | } | ||||
| @@ -198,7 +198,22 @@ static inline LogStream &operator<<(LogStream &stream, DeviceType device_type) { | |||||
| stream << "kDeviceTypeNotSpecified"; | stream << "kDeviceTypeNotSpecified"; | ||||
| break; | break; | ||||
| default: | default: | ||||
| stream << "[device type " << static_cast<int>(device_type) << "]"; | |||||
| stream << "[device type: " << static_cast<int>(device_type) << "]"; | |||||
| break; | |||||
| } | |||||
| return stream; | |||||
| } | |||||
| static inline LogStream &operator<<(LogStream &stream, api::ModelType model_type) { | |||||
| switch (model_type) { | |||||
| case api::kMindIR: | |||||
| stream << "kMindIR"; | |||||
| break; | |||||
| case api::kOM: | |||||
| stream << "kOM"; | |||||
| break; | |||||
| default: | |||||
| stream << "[model type: " << static_cast<int>(model_type) << "]"; | |||||
| break; | break; | ||||
| } | } | ||||
| return stream; | return stream; | ||||
| @@ -83,11 +83,12 @@ Status MindSporeModelWrap::LoadModelFromFile(serving::DeviceType device_type, ui | |||||
| std::shared_ptr<api::Model> model = nullptr; | std::shared_ptr<api::Model> model = nullptr; | ||||
| try { | try { | ||||
| api::Context::Instance().SetDeviceTarget(api::kDeviceTypeAscend310).SetDeviceID(device_id); | |||||
| api::Context::Instance().SetDeviceTarget(device_type_str).SetDeviceID(device_id); | |||||
| auto graph = api::Serialization::LoadModel(file_name, model_type); | auto graph = api::Serialization::LoadModel(file_name, model_type); | ||||
| model = std::make_shared<api::Model>(api::GraphCell(graph)); | model = std::make_shared<api::Model>(api::GraphCell(graph)); | ||||
| } catch (std::runtime_error &ex) { | } catch (std::runtime_error &ex) { | ||||
| MSI_LOG_ERROR << "Load model from file failed, device_type " << device_type_str << ", device_id " << device_id; | |||||
| MSI_LOG_ERROR << "Load model from file failed, device_type: '" << device_type_str << "', device_id: " << device_id | |||||
| << ", model type: " << model_type; | |||||
| return FAILED; | return FAILED; | ||||
| } | } | ||||
| api::Status status = model->Build({}); | api::Status status = model->Build({}); | ||||