From c1f8dd2a23e0f4a2f20a45f6396bb7ec2e78aa70 Mon Sep 17 00:00:00 2001 From: "yudong.cai" Date: Tue, 5 Nov 2019 17:39:33 +0800 Subject: [PATCH] #200 disable search resource has only CPU --- core/conf/server_config.template | 3 ++- core/src/server/Config.cpp | 18 ++++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/core/conf/server_config.template b/core/conf/server_config.template index 48d29a10..4a1432ee 100644 --- a/core/conf/server_config.template +++ b/core/conf/server_config.template @@ -39,6 +39,7 @@ engine_config: gpu_search_threshold: 1000 # threshold beyond which the search computation is executed on GPUs only resource_config: - search_resources: # define the GPUs used for search computation, must be in format: gpux + search_resources: # define the devices used for search computation, must be in format: cpu or gpux + - cpu - gpu0 index_build_device: gpu0 # GPU used for building index, must be in format: gpux \ No newline at end of file diff --git a/core/src/server/Config.cpp b/core/src/server/Config.cpp index cc88dccf..db2f3400 100644 --- a/core/src/server/Config.cpp +++ b/core/src/server/Config.cpp @@ -716,24 +716,34 @@ Config::CheckResourceConfigSearchResources(const std::vector& value return Status(SERVER_INVALID_ARGUMENT, msg); } + bool cpu_found = false, gpu_found = false; for (auto& device : value) { if (device == "cpu") { + cpu_found = true; continue; } - if (!CheckGpuDevice(device).ok()) { + if (CheckGpuDevice(device).ok()) { + gpu_found = true; + } else { std::string msg = "Invalid search resource: " + device + ". Possible reason: resource_config.search_resources does not match your hardware."; return Status(SERVER_INVALID_ARGUMENT, msg); } } + + if (cpu_found && !gpu_found) { + std::string msg = + "Invalid search resource. Possible reason: resource_config.search_resources has only CPU resource."; + return Status(SERVER_INVALID_ARGUMENT, msg); + } return Status::OK(); } Status Config::CheckResourceConfigIndexBuildDevice(const std::string& value) { - if (value == "cpu") { - return Status::OK(); - } +// if (value == "cpu") { +// return Status::OK(); +// } if (!CheckGpuDevice(value).ok()) { std::string msg = "Invalid index build device: " + value + ". Possible reason: resource_config.index_build_device does not match your hardware."; -- GitLab