From dab408b8275848818dce6b5d949cf79f93dbcb03 Mon Sep 17 00:00:00 2001 From: HexToString <506181616@qq.com> Date: Wed, 7 Apr 2021 20:47:53 +0800 Subject: [PATCH] fix little bug on localWebService --- python/examples/ocr/ocr_debugger_server.py | 2 +- python/paddle_serving_server/web_service.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/python/examples/ocr/ocr_debugger_server.py b/python/examples/ocr/ocr_debugger_server.py index 13d29fe4..88dd94a8 100644 --- a/python/examples/ocr/ocr_debugger_server.py +++ b/python/examples/ocr/ocr_debugger_server.py @@ -106,7 +106,7 @@ ocr_service.load_model_config("ocr_rec_model") ocr_service.prepare_server(workdir="workdir", port=9292) ocr_service.init_det_debugger(det_model_config="ocr_det_model") if sys.argv[1] == 'gpu': - ocr_service.set_gpus("2") + ocr_service.set_gpus("0") ocr_service.run_debugger_service(gpu=True) elif sys.argv[1] == 'cpu': ocr_service.run_debugger_service() diff --git a/python/paddle_serving_server/web_service.py b/python/paddle_serving_server/web_service.py index 83d11184..fa7f4d94 100644 --- a/python/paddle_serving_server/web_service.py +++ b/python/paddle_serving_server/web_service.py @@ -267,6 +267,10 @@ class WebService(object): from paddle_serving_app.local_predict import LocalPredictor self.client = LocalPredictor() if gpu: + # if user forget to call function `set_gpus` to set self.gpus. + # default self.gpus = [0]. + if len(self.gpus) == 0: + self.gpus.append(0) self.client.load_model_config( "{}".format(self.model_config), use_gpu=True, gpu_id=self.gpus[0]) else: -- GitLab