Commit c1f8dd2a authored by 蔡宇东's avatar 蔡宇东
Browse files

#200 disable search resource has only CPU

parent 7a759709
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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
+14 −4
Original line number Diff line number Diff line
@@ -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.";