From 73361b03f5c98c53608e2b34fa51344d240fe43c Mon Sep 17 00:00:00 2001 From: ShiningZhang Date: Mon, 27 Sep 2021 20:00:38 +0800 Subject: [PATCH] support set xpu id --- paddle_inference/paddle/include/paddle_engine.h | 1 + python/paddle_serving_app/local_predict.py | 1 + python/pipeline/local_service_handler.py | 4 ++++ 3 files changed, 6 insertions(+) diff --git a/paddle_inference/paddle/include/paddle_engine.h b/paddle_inference/paddle/include/paddle_engine.h index 7cc8120f4..c76147b68 100644 --- a/paddle_inference/paddle/include/paddle_engine.h +++ b/paddle_inference/paddle/include/paddle_engine.h @@ -266,6 +266,7 @@ class PaddleInferenceEngine : public EngineCore { if (engine_conf.has_use_xpu() && engine_conf.use_xpu()) { // 2 MB l3 cache config.EnableXpu(2 * 1024 * 1024); + config.SetXpuDeviceId(gpu_id); } if (engine_conf.has_enable_memory_optimization() && diff --git a/python/paddle_serving_app/local_predict.py b/python/paddle_serving_app/local_predict.py index afe4ba62d..7de419530 100644 --- a/python/paddle_serving_app/local_predict.py +++ b/python/paddle_serving_app/local_predict.py @@ -219,6 +219,7 @@ def load_model_config(self, if use_xpu: # 2MB l3 cache config.enable_xpu(8 * 1024 * 1024) + config.set_xpu_device_id(gpu_id) # set cpu low precision if not use_gpu and not use_lite: if precision_type == paddle_infer.PrecisionType.Int8: diff --git a/python/pipeline/local_service_handler.py b/python/pipeline/local_service_handler.py index d04b96547..d9df5e309 100644 --- a/python/pipeline/local_service_handler.py +++ b/python/pipeline/local_service_handler.py @@ -280,6 +280,10 @@ def _prepare_one_server(self, workdir, port, gpuid, thread_num, mem_optim, server.set_gpuid(gpuid) # TODO: support arm or arm + xpu later server.set_device(self._device_name) + if self._use_xpu: + server.set_xpu() + if self._use_lite: + server.set_lite() server.set_op_sequence(op_seq_maker.get_op_sequence()) server.set_num_threads(thread_num)