Commit 0d1923c6 authored by 蔡宇东's avatar 蔡宇东
Browse files

#346 update gpu resource config APIs

parent 00a21da4
Loading
Loading
Loading
Loading
+8 −7
Original line number Diff line number Diff line
@@ -27,9 +27,7 @@ metric_config:
    port: 8080                      # port prometheus uses to fetch metrics, must in range [1025, 65534]

cache_config:

  cpu_cache_capacity: 16            # GB, CPU memory used for cache, must be a positive integer
  cpu_cache_threshold: 0.85         # percentage of data that will be kept when cache cleanup is triggered, must be in range (0.0, 1.0]
  cpu_cache_capacity: 16            # GB, size of CPU memory used for cache, must be a positive integer
  cache_insert_data: false          # whether to load inserted data into cache, must be a boolean

engine_config:
@@ -37,7 +35,10 @@ engine_config:
                                    # if nq >= use_blas_threshold, use OpenBlas, slower with stable response times
  gpu_search_threshold: 1000        # threshold beyond which the search computation is executed on GPUs only

resource_config:
  search_resources:                 # define the device used for search computation
    - cpu
  index_build_device: cpu           # CPU used for building index
gpu_resource_config:
  enable_gpu: true                  # whether to enable GPU resources
  cache_capacity: 4                 # GB, size of GPU memory per card used for cache, must be a positive integer
  search_resources:                 # define the GPU devices used for search computation, must be in format gpux
    - gpu0
  build_index_resources:            # define the GPU devices used for index building, must be in format gpux
    - gpu0
 No newline at end of file
+7 −8
Original line number Diff line number Diff line
@@ -27,10 +27,7 @@ metric_config:
    port: 8080                      # port prometheus uses to fetch metrics, must in range [1025, 65534]

cache_config:
  cpu_cache_capacity: 16            # GB, CPU memory used for cache, must be a positive integer
  cpu_cache_threshold: 0.85         # percentage of data that will be kept when cache cleanup is triggered, must be in range (0.0, 1.0]
  gpu_cache_capacity: 4             # GB, GPU memory used for cache, must be a positive integer
  gpu_cache_threshold: 0.85         # percentage of data that will be kept when cache cleanup is triggered, must be in range (0.0, 1.0]
  cpu_cache_capacity: 16            # GB, size of CPU memory used for cache, must be a positive integer
  cache_insert_data: false          # whether to load inserted data into cache, must be a boolean

engine_config:
@@ -38,8 +35,10 @@ engine_config:
                                    # if nq >= use_blas_threshold, use OpenBlas, slower with stable response times
  gpu_search_threshold: 1000        # threshold beyond which the search computation is executed on GPUs only

resource_config:
  search_resources:                 # define the devices used for search computation, must be in format: cpu or gpux
    - cpu
gpu_resource_config:
  enable_gpu: false                 # whether to enable GPU resources
  cache_capacity: 4                 # GB, size of GPU memory per card used for cache, must be a positive integer
  search_resources:                 # define the GPU devices used for search computation, must be in format gpux
    - gpu0
  build_index_resources:            # define the GPU devices used for index building, must be in format gpux
    - gpu0
 No newline at end of file
  index_build_device: gpu0          # CPU / GPU used for building index, must be in format: cpu or gpux
+2 −2
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ GpuCacheMgr::GpuCacheMgr() {
    Status s;

    int64_t gpu_cache_cap;
    s = config.GetCacheConfigGpuCacheCapacity(gpu_cache_cap);
    s = config.GetGpuResourceConfigCacheCapacity(gpu_cache_cap);
    if (!s.ok()) {
        SERVER_LOG_ERROR << s.message();
    }
@@ -45,7 +45,7 @@ GpuCacheMgr::GpuCacheMgr() {
    cache_ = std::make_shared<Cache<DataObjPtr>>(cap, 1UL << 32);

    float gpu_mem_threshold;
    s = config.GetCacheConfigGpuCacheThreshold(gpu_mem_threshold);
    s = config.GetGpuResourceConfigCacheThreshold(gpu_mem_threshold);
    if (!s.ok()) {
        SERVER_LOG_ERROR << s.message();
    }
+232 −212

File changed.

Preview size limit exceeded, changes collapsed.

+40 −47
Original line number Diff line number Diff line
@@ -59,12 +59,8 @@ static const char* CONFIG_DB_PRELOAD_TABLE = "preload_table";
static const char* CONFIG_CACHE = "cache_config";
static const char* CONFIG_CACHE_CPU_CACHE_CAPACITY = "cpu_cache_capacity";
static const char* CONFIG_CACHE_CPU_CACHE_CAPACITY_DEFAULT = "16";
static const char* CONFIG_CACHE_GPU_CACHE_CAPACITY = "gpu_cache_capacity";
static const char* CONFIG_CACHE_GPU_CACHE_CAPACITY_DEFAULT = "4";
static const char* CONFIG_CACHE_CPU_CACHE_THRESHOLD = "cpu_mem_threshold";
static const char* CONFIG_CACHE_CPU_CACHE_THRESHOLD = "cpu_cache_threshold";
static const char* CONFIG_CACHE_CPU_CACHE_THRESHOLD_DEFAULT = "0.85";
static const char* CONFIG_CACHE_GPU_CACHE_THRESHOLD = "gpu_mem_threshold";
static const char* CONFIG_CACHE_GPU_CACHE_THRESHOLD_DEFAULT = "0.85";
static const char* CONFIG_CACHE_CACHE_INSERT_DATA = "cache_insert_data";
static const char* CONFIG_CACHE_CACHE_INSERT_DATA_DEFAULT = "false";

@@ -87,26 +83,23 @@ static const char* CONFIG_ENGINE_OMP_THREAD_NUM_DEFAULT = "0";
static const char* CONFIG_ENGINE_GPU_SEARCH_THRESHOLD = "gpu_search_threshold";
static const char* CONFIG_ENGINE_GPU_SEARCH_THRESHOLD_DEFAULT = "1000";

/* resource config */
static const char* CONFIG_RESOURCE = "resource_config";
static const char* CONFIG_RESOURCE_MODE = "mode";
static const char* CONFIG_RESOURCE_MODE_DEFAULT = "simple";
static const char* CONFIG_RESOURCE_SEARCH_RESOURCES = "search_resources";
static const char* CONFIG_RESOURCE_SEARCH_RESOURCES_DELIMITER = ",";

#ifdef MILVUS_CPU_VERSION
static const char* CONFIG_RESOURCE_SEARCH_RESOURCES_DEFAULT = "cpu";
#else
static const char* CONFIG_RESOURCE_SEARCH_RESOURCES_DEFAULT = "cpu,gpu0";
#endif

static const char* CONFIG_RESOURCE_INDEX_BUILD_DEVICE = "index_build_device";
#ifdef MILVUS_CPU_VERSION
static const char* CONFIG_RESOURCE_INDEX_BUILD_DEVICE_DEFAULT = "cpu";
/* gpu resource config */
static const char* CONFIG_GPU_RESOURCE = "gpu_resource_config";
static const char* CONFIG_GPU_RESOURCE_ENABLE_GPU = "enable_gpu";
#ifdef MILVUS_GPU_VERSION
static const char* CONFIG_GPU_RESOURCE_ENABLE_GPU_DEFAULT = "true";
#else
static const char* CONFIG_RESOURCE_INDEX_BUILD_DEVICE_DEFAULT = "gpu0";
static const char* CONFIG_GPU_RESOURCE_ENABLE_GPU_DEFAULT = "false";
#endif
const int32_t CPU_DEVICE_ID = -1;
static const char* CONFIG_GPU_RESOURCE_CACHE_CAPACITY = "cache_capacity";
static const char* CONFIG_GPU_RESOURCE_CACHE_CAPACITY_DEFAULT = "4";
static const char* CONFIG_GPU_RESOURCE_CACHE_THRESHOLD = "cache_threshold";
static const char* CONFIG_GPU_RESOURCE_CACHE_THRESHOLD_DEFAULT = "0.85";
static const char* CONFIG_GPU_RESOURCE_DELIMITER = ",";
static const char* CONFIG_GPU_RESOURCE_SEARCH_RESOURCES = "search_resources";
static const char* CONFIG_GPU_RESOURCE_SEARCH_RESOURCES_DEFAULT = "gpu0";
static const char* CONFIG_GPU_RESOURCE_BUILD_INDEX_RESOURCES = "build_index_resources";
static const char* CONFIG_GPU_RESOURCE_BUILD_INDEX_RESOURCES_DEFAULT = "gpu0";

class Config {
 public:
@@ -170,10 +163,6 @@ class Config {
    Status
    CheckCacheConfigCpuCacheThreshold(const std::string& value);
    Status
    CheckCacheConfigGpuCacheCapacity(const std::string& value);
    Status
    CheckCacheConfigGpuCacheThreshold(const std::string& value);
    Status
    CheckCacheConfigCacheInsertData(const std::string& value);

    /* engine config */
@@ -184,13 +173,17 @@ class Config {
    Status
    CheckEngineConfigGpuSearchThreshold(const std::string& value);

    /* resource config */
    /* gpu resource config */
    Status
    CheckGpuResourceConfigEnableGpu(const std::string& value);
    Status
    CheckGpuResourceConfigCacheCapacity(const std::string& value);
    Status
    CheckResourceConfigMode(const std::string& value);
    CheckGpuResourceConfigCacheThreshold(const std::string& value);
    Status
    CheckResourceConfigSearchResources(const std::vector<std::string>& value);
    CheckGpuResourceConfigSearchResources(const std::vector<std::string>& value);
    Status
    CheckResourceConfigIndexBuildDevice(const std::string& value);
    CheckGpuResourceConfigBuildIndexResources(const std::vector<std::string>& value);

    std::string
    GetConfigStr(const std::string& parent_key, const std::string& child_key, const std::string& default_value = "");
@@ -239,10 +232,6 @@ class Config {
    Status
    GetCacheConfigCpuCacheThreshold(float& value);
    Status
    GetCacheConfigGpuCacheCapacity(int64_t& value);
    Status
    GetCacheConfigGpuCacheThreshold(float& value);
    Status
    GetCacheConfigCacheInsertData(bool& value);

    /* engine config */
@@ -253,13 +242,17 @@ class Config {
    Status
    GetEngineConfigGpuSearchThreshold(int32_t& value);

    /* resource config */
    /* gpu resource config */
    Status
    GetGpuResourceConfigEnableGpu(bool& value);
    Status
    GetGpuResourceConfigCacheCapacity(int64_t& value);
    Status
    GetResourceConfigMode(std::string& value);
    GetGpuResourceConfigCacheThreshold(float& value);
    Status
    GetResourceConfigSearchResources(std::vector<std::string>& value);
    GetGpuResourceConfigSearchResources(std::vector<int32_t>& value);
    Status
    GetResourceConfigIndexBuildDevice(int32_t& value);
    GetGpuResourceConfigBuildIndexResources(std::vector<int32_t>& value);

 public:
    /* server config */
@@ -300,10 +293,6 @@ class Config {
    Status
    SetCacheConfigCpuCacheThreshold(const std::string& value);
    Status
    SetCacheConfigGpuCacheCapacity(const std::string& value);
    Status
    SetCacheConfigGpuCacheThreshold(const std::string& value);
    Status
    SetCacheConfigCacheInsertData(const std::string& value);

    /* engine config */
@@ -314,13 +303,17 @@ class Config {
    Status
    SetEngineConfigGpuSearchThreshold(const std::string& value);

    /* resource config */
    /* gpu resource config */
    Status
    SetGpuResourceConfigEnableGpu(const std::string& value);
    Status
    SetGpuResourceConfigCacheCapacity(const std::string& value);
    Status
    SetResourceConfigMode(const std::string& value);
    SetGpuResourceConfigCacheThreshold(const std::string& value);
    Status
    SetResourceConfigSearchResources(const std::string& value);
    SetGpuResourceConfigSearchResources(const std::string& value);
    Status
    SetResourceConfigIndexBuildDevice(const std::string& value);
    SetGpuResourceConfigBuildIndexResources(const std::string& value);

 private:
    std::unordered_map<std::string, std::unordered_map<std::string, std::string>> config_map_;
Loading