diff --git a/python/paddle_serving_server/__init__.py b/python/paddle_serving_server/__init__.py index d893861e2b0cc1615701191a66aa6ff0bcb53305..08f3febc14ecd0d3c3cde7dc54f17bd143f9d5b3 100644 --- a/python/paddle_serving_server/__init__.py +++ b/python/paddle_serving_server/__init__.py @@ -211,6 +211,7 @@ class Server(object): tar_name = floder_name + ".tar.gz" bin_url = "https://paddle-serving.bj.bcebos.com/bin/" + tar_name self.server_path = os.path.join(self.module_path, floder_name) + if not os.path.exists(self.server_path): print('Frist time run, downloading PaddleServing components ...') r = os.system('wget ' + bin_url + ' --no-check-certificate') diff --git a/python/paddle_serving_server_gpu/__init__.py b/python/paddle_serving_server_gpu/__init__.py index 3dd330b18921c81cf17601ff7e52d860f0322f95..abe93a1ce74fa846774425827b9a3ebbdc670450 100644 --- a/python/paddle_serving_server_gpu/__init__.py +++ b/python/paddle_serving_server_gpu/__init__.py @@ -20,6 +20,7 @@ import google.protobuf.text_format import tarfile import socket import paddle_serving_server_gpu as paddle_serving_server +import time from .version import serving_server_version from contextlib import closing import argparse @@ -215,11 +216,21 @@ class Server(object): os.chdir(self.module_path) need_download = False device_version = "serving-gpu-" - floder_name = device_version + serving_server_version - tar_name = floder_name + ".tar.gz" + folder_name = device_version + serving_server_version + tar_name = folder_name + ".tar.gz" bin_url = "https://paddle-serving.bj.bcebos.com/bin/" + tar_name - self.server_path = os.path.join(self.module_path, floder_name) + self.server_path = os.path.join(self.module_path, folder_name) + + download_flag = "{}/{}.is_download".format(self.module_path, + folder_name) + if os.path.exists(download_flag): + os.chdir(self.cur_path) + self.bin_path = self.server_path + "/serving" + return + if not os.path.exists(self.server_path): + os.system("touch {}/{}.is_download".format(self.module_path, + folder_name)) print('Frist time run, downloading PaddleServing components ...') r = os.system('wget ' + bin_url + ' --no-check-certificate') if r != 0: @@ -318,4 +329,8 @@ class Server(object): self.gpuid,) print("Going to Run Comand") print(command) + # wait for other process to download server bin + while not os.path.exists(self.server_path): + time.sleep(1) + os.system(command) diff --git a/python/paddle_serving_server_gpu/web_service.py b/python/paddle_serving_server_gpu/web_service.py index db0db25d749728dc99dc1e65c278741d4b4bd5ae..5d507c9475047d6c7eb65a2b2c5799221cf194b5 100755 --- a/python/paddle_serving_server_gpu/web_service.py +++ b/python/paddle_serving_server_gpu/web_service.py @@ -66,6 +66,12 @@ class WebService(object): return server def _launch_rpc_service(self, service_idx): + if service_idx == 0: + self.rpc_service_list[service_idx].check_local_bin() + if not self.rpc_service_list[service_idx].use_local_bin: + self.rpc_service_list[service_idx].download_bin() + else: + time.sleep(3) self.rpc_service_list[service_idx].run_server() def prepare_server(self, workdir="", port=9393, device="gpu", gpuid=0): @@ -160,15 +166,6 @@ class WebService(object): if not isinstance(result, dict) and result == -1: result = {"result": "Request Value Error"} return result - ''' - feed, fetch = self.preprocess(request.json, request.json["fetch"]) - if "fetch" in feed: - del feed["fetch"] - fetch_map = client.predict(feed=feed, fetch=fetch) - fetch_map = self.postprocess( - feed=request.json, fetch=fetch, fetch_map=fetch_map) - return fetch_map - ''' app_instance.run(host="0.0.0.0", port=self.port,