diff --git a/CHANGELOG.md b/CHANGELOG.md index c5f412adec2368468997005cc701755121b0ef29..a77a09f636566d3ab1229be2cbc62c4475f067b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ Please mark all change in change log and use the issue from GitHub ## Bug - \#1705 Limit the insert data batch size - \#1929 Skip MySQL meta schema field width check +- \#1946 Fix load index file CPU2GPU fail during searching - \#1997 Index file missed after compact - \#2073 Fix CheckDBConfigBackendUrl error message - \#2076 CheckMetricConfigAddress error message diff --git a/core/src/index/knowhere/knowhere/index/vector_index/helpers/FaissGpuResourceMgr.cpp b/core/src/index/knowhere/knowhere/index/vector_index/helpers/FaissGpuResourceMgr.cpp index 051c5496d4914e0dcdfd9364031e428346bb24a5..b315f538c999f09f5d1d1bc4ea3b7cc97a5c8a07 100644 --- a/core/src/index/knowhere/knowhere/index/vector_index/helpers/FaissGpuResourceMgr.cpp +++ b/core/src/index/knowhere/knowhere/index/vector_index/helpers/FaissGpuResourceMgr.cpp @@ -51,29 +51,31 @@ FaissGpuResourceMgr::InitDevice(int64_t device_id, int64_t pin_mem_size, int64_t void FaissGpuResourceMgr::InitResource() { - if (is_init) - return; + if (!initialized_) { + std::lock_guard lock(init_mutex_); - is_init = true; + if (!initialized_) { + for (auto& device : devices_params_) { + auto& device_id = device.first; - for (auto& device : devices_params_) { - auto& device_id = device.first; + mutex_cache_.emplace(device_id, std::make_unique()); - mutex_cache_.emplace(device_id, std::make_unique()); + auto& device_param = device.second; + auto& bq = idle_map_[device_id]; - auto& device_param = device.second; - auto& bq = idle_map_[device_id]; + for (int64_t i = 0; i < device_param.resource_num; ++i) { + auto raw_resource = std::make_shared(); - for (int64_t i = 0; i < device_param.resource_num; ++i) { - auto raw_resource = std::make_shared(); + // TODO(linxj): enable set pinned memory + auto res_wrapper = std::make_shared(raw_resource); + AllocateTempMem(res_wrapper, device_id, 0); - // TODO(linxj): enable set pinned memory - auto res_wrapper = std::make_shared(raw_resource); - AllocateTempMem(res_wrapper, device_id, 0); - - bq.Put(res_wrapper); + bq.Put(res_wrapper); + } + LOG_KNOWHERE_DEBUG_ << "DEVICEID " << device_id << ", resource count " << bq.Size(); + } + initialized_ = true; } - LOG_KNOWHERE_DEBUG_ << "DEVICEID " << device_id << ", resource count " << bq.Size(); } } @@ -115,7 +117,7 @@ FaissGpuResourceMgr::Free() { bq.Take(); } } - is_init = false; + initialized_ = false; } void diff --git a/core/src/index/knowhere/knowhere/index/vector_index/helpers/FaissGpuResourceMgr.h b/core/src/index/knowhere/knowhere/index/vector_index/helpers/FaissGpuResourceMgr.h index e97b2ab05b9e78de792dbef671c164e79130560c..5c3ee2aa839f0f3233ddc3794127659e7d9ca6d8 100644 --- a/core/src/index/knowhere/knowhere/index/vector_index/helpers/FaissGpuResourceMgr.h +++ b/core/src/index/knowhere/knowhere/index/vector_index/helpers/FaissGpuResourceMgr.h @@ -77,7 +77,8 @@ class FaissGpuResourceMgr { Dump(); protected: - bool is_init = false; + bool initialized_ = false; + std::mutex init_mutex_; std::map> mutex_cache_; std::map devices_params_;