提交 1af86e73 编写于 作者: H HexToString

fix config error

上级 7c81963e
......@@ -96,7 +96,6 @@ int ServerManager::start_and_wait() {
LOG(ERROR) << "Failed to start Paddle Inference Server";
return -1;
}
LOG(WARNING) << "Finsh start C++ PaddleServing.";
_server.RunUntilAskedToQuit();
ServerManager::stop_reloader();
......
......@@ -41,6 +41,8 @@ from multiprocessing import Pool, Process
from concurrent import futures
# The whole file is about to be discarded.
# We will use default config-file to start C++Server.
class Server(object):
def __init__(self):
"""
......@@ -172,8 +174,7 @@ class Server(object):
if isinstance(gpuid, int):
self.gpuid = str(gpuid)
elif isinstance(gpuid, list):
gpu_list = [str(x) for x in gpuid]
self.gpuid = ",".join(gpu_list)
self.gpuid = [str(x) for x in gpuid]
else:
self.gpuid = gpuid
......@@ -200,8 +201,14 @@ class Server(object):
self.model_toolkit_conf = []
self.device = device
# Generally, self.gpuid = str[] or str.
# such as "0" or ["0"] or ["0,1"] or ["0,1" , "1,2"]
if isinstance(self.gpuid, str):
self.gpuid = [self.gpuid]
# when len(self.gpuid) means no gpuid is specified.
# if self.device == "gpu" or self.use_trt:
# we assume you forget to set gpuid, so set gpuid = ['0'];
if len(self.gpuid) == 0:
if self.device == "gpu" or self.use_trt:
self.gpuid.append("0")
......@@ -240,8 +247,6 @@ class Server(object):
engine.use_lite = self.use_lite
engine.use_xpu = self.use_xpu
engine.use_gpu = False
if self.device == "gpu" or self.use_trt:
engine.use_gpu = True
if len(self.gpuid) == 0:
raise ValueError("CPU: self.gpuid = -1, GPU: must set it ")
......@@ -249,6 +254,18 @@ class Server(object):
for ids in op_gpu_list:
engine.gpu_ids.extend([int(ids)])
if self.device == "gpu" or self.use_trt:
engine.use_gpu = True
# this is for Mixed use of GPU and CPU
# if model-1 use GPU and set the device="gpu"
# but gpuid[1] = "-1" which means use CPU in Model-2
# so config about GPU should be False.
if len(op_gpu_list) == 1:
if int(op_gpu_list[0]) == -1:
engine.use_gpu = False
engine.gpu_multi_stream = False
engine.use_trt = False
if os.path.exists('{}/__params__'.format(model_config_path)):
engine.combined_model = True
else:
......@@ -540,71 +557,38 @@ class Server(object):
else:
print("Use local bin : {}".format(self.bin_path))
#self.check_cuda()
# Todo: merge CPU and GPU code, remove device to model_toolkit
if self.device == "cpu" or self.device == "arm":
command = "{} " \
"-enable_model_toolkit " \
"-inferservice_path {} " \
"-inferservice_file {} " \
"-max_concurrency {} " \
"-num_threads {} " \
"-port {} " \
"-precision {} " \
"-use_calib {} " \
"-reload_interval_s {} " \
"-resource_path {} " \
"-resource_file {} " \
"-workflow_path {} " \
"-workflow_file {} " \
"-bthread_concurrency {} " \
"-max_body_size {} ".format(
self.bin_path,
self.workdir,
self.infer_service_fn,
self.max_concurrency,
self.num_threads,
self.port,
self.precision,
self.use_calib,
self.reload_interval_s,
self.workdir,
self.resource_fn,
self.workdir,
self.workflow_fn,
self.num_threads,
self.max_body_size)
else:
command = "{} " \
"-enable_model_toolkit " \
"-inferservice_path {} " \
"-inferservice_file {} " \
"-max_concurrency {} " \
"-num_threads {} " \
"-port {} " \
"-precision {} " \
"-use_calib {} " \
"-reload_interval_s {} " \
"-resource_path {} " \
"-resource_file {} " \
"-workflow_path {} " \
"-workflow_file {} " \
"-bthread_concurrency {} " \
"-max_body_size {} ".format(
self.bin_path,
self.workdir,
self.infer_service_fn,
self.max_concurrency,
self.num_threads,
self.port,
self.precision,
self.use_calib,
self.reload_interval_s,
self.workdir,
self.resource_fn,
self.workdir,
self.workflow_fn,
self.num_threads,
self.max_body_size)
command = "{} " \
"-enable_model_toolkit " \
"-inferservice_path {} " \
"-inferservice_file {} " \
"-max_concurrency {} " \
"-num_threads {} " \
"-port {} " \
"-precision {} " \
"-use_calib {} " \
"-reload_interval_s {} " \
"-resource_path {} " \
"-resource_file {} " \
"-workflow_path {} " \
"-workflow_file {} " \
"-bthread_concurrency {} " \
"-max_body_size {} ".format(
self.bin_path,
self.workdir,
self.infer_service_fn,
self.max_concurrency,
self.num_threads,
self.port,
self.precision,
self.use_calib,
self.reload_interval_s,
self.workdir,
self.resource_fn,
self.workdir,
self.workflow_fn,
self.num_threads,
self.max_body_size)
print("Going to Run Comand")
print(command)
......
......@@ -108,8 +108,7 @@ class WebService(object):
if isinstance(gpus, int):
self.gpus = str(gpus)
elif isinstance(gpus, list):
gpu_list = [str(x) for x in gpus]
self.gpus = ",".join(gpu_list)
self.gpus = [str(x) for x in gpus]
else:
self.gpus = gpus
......@@ -261,8 +260,7 @@ class WebService(object):
if isinstance(gpuid, int):
self.gpus = str(gpuid)
elif isinstance(gpuid, list):
gpu_list = [str(x) for x in gpuid]
self.gpus = ",".join(gpu_list)
self.gpus = [str(x) for x in gpuid]
else:
self.gpus = gpuid
......@@ -363,7 +361,8 @@ class WebService(object):
# default self.gpus = [0].
if len(self.gpus) == 0:
self.gpus.append(0)
# right now, local Predictor only support 1 card.
# no matter how many gpu_id is in gpus, we only use the first one.
gpu_id = (self.gpus[0].split(","))[0]
self.client.load_model_config(
self.server_config_dir_paths[0], use_gpu=True, gpu_id=gpu_id)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册