提交 c1f8dd2a 编写于 作者: Y yudong.cai

#200 disable search resource has only CPU

上级 7a759709
......@@ -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
......@@ -716,24 +716,34 @@ Config::CheckResourceConfigSearchResources(const std::vector<std::string>& 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.";
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册