提交 ea05330f 编写于 作者: B barriery

update demo

上级 7abd7a5c
port: 18080 port: 18080
worker_num: 1 worker_num: 4
build_dag_each_worker: false build_dag_each_worker: false
dag: dag:
is_thread_op: true is_thread_op: false
client_type: brpc client_type: brpc
retry: 1 retry: 1
use_profile: false use_profile: false
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from paddle_serving_client.pipeline import PipelineClient from paddle_serving_server_gpu.pipeline import PipelineClient
import numpy as np import numpy as np
client = PipelineClient() client = PipelineClient()
...@@ -20,12 +20,16 @@ client.connect(['127.0.0.1:18080']) ...@@ -20,12 +20,16 @@ client.connect(['127.0.0.1:18080'])
words = 'i am very sad | 0' words = 'i am very sad | 0'
futures = [] futures = []
for i in range(100): for i in range(4):
futures.append( futures.append(
client.predict( client.predict(
feed_dict={"words": words}, fetch=["prediction"], asyn=True)) feed_dict={"words": words},
fetch=["prediction"],
asyn=True,
profile=False))
for f in futures: for f in futures:
res = f.result() res = f.result()
if res["ecode"] != 0: if res["ecode"] != 0:
print("predict failed: {}".format(res)) print("predict failed: {}".format(res))
print(res)
...@@ -14,7 +14,8 @@ ...@@ -14,7 +14,8 @@
# pylint: disable=doc-string-missing # pylint: disable=doc-string-missing
import logging import logging
logging.basicConfig(format='%(levelname)s:%(asctime)s:%(message)s', logging.basicConfig(
format="[%(process)d](%(threadName)s) %(levelname)s %(asctime)s [%(funcName)s:%(lineno)d] %(message)s",
level=logging.INFO) level=logging.INFO)
from paddle_serving_server_gpu.pipeline import Op, RequestOp, ResponseOp from paddle_serving_server_gpu.pipeline import Op, RequestOp, ResponseOp
...@@ -26,6 +27,7 @@ from paddle_serving_app.reader import IMDBDataset ...@@ -26,6 +27,7 @@ from paddle_serving_app.reader import IMDBDataset
_LOGGER = logging.getLogger() _LOGGER = logging.getLogger()
class ImdbRequestOp(RequestOp): class ImdbRequestOp(RequestOp):
def init_op(self): def init_op(self):
self.imdb_dataset = IMDBDataset() self.imdb_dataset = IMDBDataset()
...@@ -51,6 +53,7 @@ class CombineOp(Op): ...@@ -51,6 +53,7 @@ class CombineOp(Op):
data = {"prediction": combined_prediction / 2} data = {"prediction": combined_prediction / 2}
return data return data
class ImdbResponseOp(ResponseOp): class ImdbResponseOp(ResponseOp):
# Here ImdbResponseOp is consistent with the default ResponseOp implementation # Here ImdbResponseOp is consistent with the default ResponseOp implementation
def pack_response_package(self, channeldata): def pack_response_package(self, channeldata):
...@@ -75,7 +78,9 @@ bow_op = Op(name="bow", ...@@ -75,7 +78,9 @@ bow_op = Op(name="bow",
client_config="imdb_bow_client_conf/serving_client_conf.prototxt", client_config="imdb_bow_client_conf/serving_client_conf.prototxt",
concurrency=1, concurrency=1,
timeout=-1, timeout=-1,
retry=1) retry=1,
batch_size=3,
auto_batching_timeout=1)
cnn_op = Op(name="cnn", cnn_op = Op(name="cnn",
input_ops=[read_op], input_ops=[read_op],
server_endpoints=["127.0.0.1:9292"], server_endpoints=["127.0.0.1:9292"],
...@@ -83,13 +88,17 @@ cnn_op = Op(name="cnn", ...@@ -83,13 +88,17 @@ cnn_op = Op(name="cnn",
client_config="imdb_cnn_client_conf/serving_client_conf.prototxt", client_config="imdb_cnn_client_conf/serving_client_conf.prototxt",
concurrency=1, concurrency=1,
timeout=-1, timeout=-1,
retry=1) retry=1,
batch_size=1,
auto_batching_timeout=None)
combine_op = CombineOp( combine_op = CombineOp(
name="combine", name="combine",
input_ops=[bow_op, cnn_op], input_ops=[bow_op, cnn_op],
concurrency=5, concurrency=1,
timeout=-1, timeout=-1,
retry=1) retry=1,
batch_size=2,
auto_batching_timeout=None)
# fetch output of bow_op # fetch output of bow_op
# response_op = ImdbResponseOp(input_ops=[bow_op]) # response_op = ImdbResponseOp(input_ops=[bow_op])
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册