From 025f16e5531387b76cb16aec4e2073f4d08c05f1 Mon Sep 17 00:00:00 2001 From: MRXLT Date: Tue, 31 Mar 2020 04:16:06 +0000 Subject: [PATCH] add check --- python/paddle_serving_server_gpu/serve.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/python/paddle_serving_server_gpu/serve.py b/python/paddle_serving_server_gpu/serve.py index fb2e756d..d09efbfc 100644 --- a/python/paddle_serving_server_gpu/serve.py +++ b/python/paddle_serving_server_gpu/serve.py @@ -69,11 +69,12 @@ def start_multi_card(args): # pylint: disable=doc-string-missing gpus = args.gpu_ids.split(",") if "CUDA_VISIBLE_DEVICES" in os.environ: env_gpus = os.environ["CUDA_VISIBLE_DEVICES"].split(",") - if int(gpus[-1]) >= len(env_gpus): - print( - " Max index of gpu_ids out of range, the number of CUDA_VISIBLE_DEVICES is {}.". - format(len(env_gpus))) - exit(-1) + for ids in gpus: + if int(ids) >= len(env_gpus): + print( + " Max index of gpu_ids out of range, the number of CUDA_VISIBLE_DEVICES is {}.". + format(len(env_gpus))) + exit(-1) else: env_gpus = [] if len(gpus) <= 0: -- GitLab