diff --git a/core/conf/server_config.template b/core/conf/server_config.template index 48d29a1096b29cb8c384d089cb2f81fc4c94f8c2..4a1432eea6b74889f089ae41bb72ce9c1ef515ea 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 cc88dccffa4fecded9a31b2c6e34a15b7acf5e05..db2f3400aa204774521f3ecf97aa4a44a6e15f31 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.";