diff --git a/python/examples/pipeline/imdb_model_ensemble/config.yml b/python/examples/pipeline/imdb_model_ensemble/config.yml index 7dac6eec2a2d7d90be3d4684f2aaaec7496249d9..13a85d068e2a1bbea5caa2a552ce4f26cb3b0316 100644 --- a/python/examples/pipeline/imdb_model_ensemble/config.yml +++ b/python/examples/pipeline/imdb_model_ensemble/config.yml @@ -1,8 +1,8 @@ port: 18080 -worker_num: 1 +worker_num: 4 build_dag_each_worker: false dag: - is_thread_op: true + is_thread_op: false client_type: brpc retry: 1 use_profile: false diff --git a/python/examples/pipeline/imdb_model_ensemble/test_pipeline_client.py b/python/examples/pipeline/imdb_model_ensemble/test_pipeline_client.py index 9cf476c4705c2267aa42337f90970d9fd051b7fd..aefc8dfd8463ad75d287e4d91b501fc19f7b8220 100644 --- a/python/examples/pipeline/imdb_model_ensemble/test_pipeline_client.py +++ b/python/examples/pipeline/imdb_model_ensemble/test_pipeline_client.py @@ -11,7 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -from paddle_serving_client.pipeline import PipelineClient +from paddle_serving_server_gpu.pipeline import PipelineClient import numpy as np client = PipelineClient() @@ -20,12 +20,16 @@ client.connect(['127.0.0.1:18080']) words = 'i am very sad | 0' futures = [] -for i in range(100): +for i in range(4): futures.append( client.predict( - feed_dict={"words": words}, fetch=["prediction"], asyn=True)) + feed_dict={"words": words}, + fetch=["prediction"], + asyn=True, + profile=False)) for f in futures: res = f.result() if res["ecode"] != 0: print("predict failed: {}".format(res)) + print(res) diff --git a/python/examples/pipeline/imdb_model_ensemble/test_pipeline_server.py b/python/examples/pipeline/imdb_model_ensemble/test_pipeline_server.py index 884f7476a12aadfe990c42365c42a3a4e6fafd3d..3c1f890477643402457f28144759310bc8cde587 100644 --- a/python/examples/pipeline/imdb_model_ensemble/test_pipeline_server.py +++ b/python/examples/pipeline/imdb_model_ensemble/test_pipeline_server.py @@ -14,8 +14,9 @@ # pylint: disable=doc-string-missing import logging -logging.basicConfig(format='%(levelname)s:%(asctime)s:%(message)s', - level=logging.INFO) +logging.basicConfig( + format="[%(process)d](%(threadName)s) %(levelname)s %(asctime)s [%(funcName)s:%(lineno)d] %(message)s", + level=logging.INFO) from paddle_serving_server_gpu.pipeline import Op, RequestOp, ResponseOp from paddle_serving_server_gpu.pipeline import PipelineServer @@ -26,6 +27,7 @@ from paddle_serving_app.reader import IMDBDataset _LOGGER = logging.getLogger() + class ImdbRequestOp(RequestOp): def init_op(self): self.imdb_dataset = IMDBDataset() @@ -51,6 +53,7 @@ class CombineOp(Op): data = {"prediction": combined_prediction / 2} return data + class ImdbResponseOp(ResponseOp): # Here ImdbResponseOp is consistent with the default ResponseOp implementation def pack_response_package(self, channeldata): @@ -75,7 +78,9 @@ bow_op = Op(name="bow", client_config="imdb_bow_client_conf/serving_client_conf.prototxt", concurrency=1, timeout=-1, - retry=1) + retry=1, + batch_size=3, + auto_batching_timeout=1) cnn_op = Op(name="cnn", input_ops=[read_op], server_endpoints=["127.0.0.1:9292"], @@ -83,13 +88,17 @@ cnn_op = Op(name="cnn", client_config="imdb_cnn_client_conf/serving_client_conf.prototxt", concurrency=1, timeout=-1, - retry=1) + retry=1, + batch_size=1, + auto_batching_timeout=None) combine_op = CombineOp( name="combine", input_ops=[bow_op, cnn_op], - concurrency=5, + concurrency=1, timeout=-1, - retry=1) + retry=1, + batch_size=2, + auto_batching_timeout=None) # fetch output of bow_op # response_op = ImdbResponseOp(input_ops=[bow_op])