提交 e290b617 编写于 作者: D Dong Daxiang 提交者: guru4elephant

fix paddle_serving_server.serve

if a user does not define gpus_ids, current api will find gpus through CUDA_VISIBLE_DEVICES
otherwise, the server will startup cpu services as needed.
上级 55682764
......@@ -93,6 +93,8 @@ print(fetch_map)
[Compile from source code(Chinese)](doc/COMPILE.md)
[How profile serving efficiency?(Chinese)](https://github.com/PaddlePaddle/Serving/tree/develop/python/examples/util)
[FAQ(Chinese)](doc/FAQ.md)
[Design Doc(Chinese)](doc/DESIGN.md)
......
......@@ -34,7 +34,7 @@ args = benchmark_args()
def single_func(idx, resource):
fin = open("data-c.txt")
if args.request == "rpc":
reader = BertReader(vocab_file="vocab.txt", max_seq_len=20)
reader = BertReader(vocab_file="vocab.txt", max_seq_len=128)
config_file = './serving_client_conf/serving_client_conf.prototxt'
fetch = ["pooled_output"]
client = Client()
......@@ -50,7 +50,6 @@ def single_func(idx, resource):
start = time.time()
header = {"Content-Type": "application/json"}
for line in fin:
#dict_data = {"words": "this is for output ", "fetch": ["pooled_output"]}
dict_data = {"words": line, "fetch": ["pooled_output"]}
r = requests.post(
'http://{}/bert/prediction'.format(resource["endpoint"][0]),
......@@ -62,10 +61,11 @@ def single_func(idx, resource):
if __name__ == '__main__':
multi_thread_runner = MultiThreadRunner()
endpoint_list = [
"127.0.0.1:9494", "127.0.0.1:9495", "127.0.0.1:9496", "127.0.0.1:9497"
]
#endpoint_list = endpoint_list + endpoint_list + endpoint_list
#result = multi_thread_runner.run(single_func, args.thread, {"endpoint":endpoint_list})
result = single_func(0, {"endpoint": endpoint_list})
endpoint_list = []
card_num = 4
for i in range(args.thread):
endpoint_list.append("127.0.0.1:{}".format(9494 + i % card_num))
print(endpoint_list)
result = multi_thread_runner.run(single_func, args.thread,
{"endpoint": endpoint_list})
print(result)
......@@ -17,8 +17,8 @@ Usage:
Example:
python -m paddle_serving_server.serve --model ./serving_server_model --port 9292
"""
import os
import argparse
import os
from multiprocessing import Pool, Process
from paddle_serving_server_gpu import serve_args
......@@ -64,12 +64,14 @@ def start_gpu_card_model(gpuid, args): # pylint: disable=doc-string-missing
def start_multi_card(args): # pylint: disable=doc-string-missing
gpus = ""
if args.gpu_ids == "":
import os
gpus = os.environ["CUDA_VISIBLE_DEVICES"]
if "CUDA_VISIBLE_DEVICES" in os.environ:
gpus = os.environ["CUDA_VISIBLE_DEVICES"]
else:
gpus = []
else:
gpus = args.gpu_ids.split(",")
if len(gpus) <= 0:
start_gpu_card_model(-1)
start_gpu_card_model(-1, args)
else:
gpu_processes = []
for i, gpu_id in enumerate(gpus):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册