From f9394351ac08808fe09aa31a56423cbee1047820 Mon Sep 17 00:00:00 2001 From: wangjiawei04 Date: Mon, 15 Jun 2020 12:01:54 +0800 Subject: [PATCH] add use_multilang option in gpu part --- python/paddle_serving_server_gpu/__init__.py | 4 +++ python/paddle_serving_server_gpu/serve.py | 31 +++++++++++++------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/python/paddle_serving_server_gpu/__init__.py b/python/paddle_serving_server_gpu/__init__.py index 44733b15..cc736a52 100644 --- a/python/paddle_serving_server_gpu/__init__.py +++ b/python/paddle_serving_server_gpu/__init__.py @@ -68,6 +68,10 @@ def serve_args(): type=int, default=512 * 1024 * 1024, help="Limit sizes of messages") + parser.add_argument( + "--use_multilang", + action='store_true', + help="Use Multi-language-service") return parser.parse_args() diff --git a/python/paddle_serving_server_gpu/serve.py b/python/paddle_serving_server_gpu/serve.py index 309896a8..0769039e 100644 --- a/python/paddle_serving_server_gpu/serve.py +++ b/python/paddle_serving_server_gpu/serve.py @@ -54,17 +54,26 @@ def start_gpu_card_model(index, gpuid, args): # pylint: disable=doc-string-miss op_seq_maker.add_op(general_infer_op) op_seq_maker.add_op(general_response_op) - server = serving.Server() - server.set_op_sequence(op_seq_maker.get_op_sequence()) - server.set_num_threads(thread_num) - server.set_memory_optimize(mem_optim) - server.set_ir_optimize(ir_optim) - server.set_max_body_size(max_body_size) - - server.load_model_config(model) - server.prepare_server(workdir=workdir, port=port, device=device) - if gpuid >= 0: - server.set_gpuid(gpuid) + use_multilang = args.use_multilang + if use_multilang: + server = serving.MultiLangServer() + server.set_op_sequence(op_seq_maker.get_op_sequence()) + server.load_model_config(model) + server.prepare_server(workdir=workdir, port=port, device=device) + if gpuid >= 0: + raise ValueError("gpuid can not >= 0 in MultiLangServer") + else: + server = serving.Server() + server.set_op_sequence(op_seq_maker.get_op_sequence()) + server.set_num_threads(thread_num) + server.set_memory_optimize(mem_optim) + server.set_ir_optimize(ir_optim) + server.set_max_body_size(max_body_size) + + server.load_model_config(model) + server.prepare_server(workdir=workdir, port=port, device=device) + if gpuid >= 0: + server.set_gpuid(gpuid) server.run_server() -- GitLab