mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-28 22:45:26 +08:00
Read gpu config only gpu_resource_config.enable=true fix #467
This commit is contained in:
parent
283fd352b4
commit
a9bc655cfb
@ -18,6 +18,7 @@ Please mark all change in change log and use the ticket from JIRA.
|
||||
- \#412 - Message returned is confused when partition created with null partition name
|
||||
- \#416 - Drop the same partition success repeatally
|
||||
- \#440 - Query API in customization still uses old version
|
||||
- \#440 - Server cannot startup with gpu_resource_config.enable=false in GPU version
|
||||
|
||||
## Feature
|
||||
- \#12 - Pure CPU version for Milvus
|
||||
|
||||
@ -54,36 +54,40 @@ load_simple_config() {
|
||||
|
||||
// get resources
|
||||
#ifdef MILVUS_GPU_VERSION
|
||||
bool enable_gpu = false;
|
||||
server::Config& config = server::Config::GetInstance();
|
||||
std::vector<int64_t> gpu_ids;
|
||||
config.GetGpuResourceConfigSearchResources(gpu_ids);
|
||||
std::vector<int64_t> build_gpu_ids;
|
||||
config.GetGpuResourceConfigBuildIndexResources(build_gpu_ids);
|
||||
auto pcie = Connection("pcie", 12000);
|
||||
config.GetGpuResourceConfigEnable(enable_gpu);
|
||||
if (enable_gpu) {
|
||||
std::vector<int64_t> gpu_ids;
|
||||
config.GetGpuResourceConfigSearchResources(gpu_ids);
|
||||
std::vector<int64_t> build_gpu_ids;
|
||||
config.GetGpuResourceConfigBuildIndexResources(build_gpu_ids);
|
||||
auto pcie = Connection("pcie", 12000);
|
||||
|
||||
std::vector<int64_t> not_find_build_ids;
|
||||
for (auto& build_id : build_gpu_ids) {
|
||||
bool find_gpu_id = false;
|
||||
for (auto& gpu_id : gpu_ids) {
|
||||
if (gpu_id == build_id) {
|
||||
find_gpu_id = true;
|
||||
break;
|
||||
std::vector<int64_t> not_find_build_ids;
|
||||
for (auto& build_id : build_gpu_ids) {
|
||||
bool find_gpu_id = false;
|
||||
for (auto& gpu_id : gpu_ids) {
|
||||
if (gpu_id == build_id) {
|
||||
find_gpu_id = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (not find_gpu_id) {
|
||||
not_find_build_ids.emplace_back(build_id);
|
||||
}
|
||||
}
|
||||
if (not find_gpu_id) {
|
||||
not_find_build_ids.emplace_back(build_id);
|
||||
|
||||
for (auto& gpu_id : gpu_ids) {
|
||||
ResMgrInst::GetInstance()->Add(ResourceFactory::Create(std::to_string(gpu_id), "GPU", gpu_id, true, true));
|
||||
ResMgrInst::GetInstance()->Connect("cpu", std::to_string(gpu_id), pcie);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto& gpu_id : gpu_ids) {
|
||||
ResMgrInst::GetInstance()->Add(ResourceFactory::Create(std::to_string(gpu_id), "GPU", gpu_id, true, true));
|
||||
ResMgrInst::GetInstance()->Connect("cpu", std::to_string(gpu_id), pcie);
|
||||
}
|
||||
|
||||
for (auto& not_find_id : not_find_build_ids) {
|
||||
ResMgrInst::GetInstance()->Add(
|
||||
ResourceFactory::Create(std::to_string(not_find_id), "GPU", not_find_id, true, true));
|
||||
ResMgrInst::GetInstance()->Connect("cpu", std::to_string(not_find_id), pcie);
|
||||
for (auto& not_find_id : not_find_build_ids) {
|
||||
ResMgrInst::GetInstance()->Add(
|
||||
ResourceFactory::Create(std::to_string(not_find_id), "GPU", not_find_id, true, true));
|
||||
ResMgrInst::GetInstance()->Connect("cpu", std::to_string(not_find_id), pcie);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -102,11 +102,16 @@ class OptimizerInst {
|
||||
if (instance == nullptr) {
|
||||
std::vector<PassPtr> pass_list;
|
||||
#ifdef MILVUS_GPU_VERSION
|
||||
pass_list.push_back(std::make_shared<BuildIndexPass>());
|
||||
pass_list.push_back(std::make_shared<FaissFlatPass>());
|
||||
pass_list.push_back(std::make_shared<FaissIVFFlatPass>());
|
||||
pass_list.push_back(std::make_shared<FaissIVFSQ8Pass>());
|
||||
pass_list.push_back(std::make_shared<FaissIVFSQ8HPass>());
|
||||
bool enable_gpu = false;
|
||||
server::Config& config = server::Config::GetInstance();
|
||||
config.GetGpuResourceConfigEnable(enable_gpu);
|
||||
if (enable_gpu) {
|
||||
pass_list.push_back(std::make_shared<BuildIndexPass>());
|
||||
pass_list.push_back(std::make_shared<FaissFlatPass>());
|
||||
pass_list.push_back(std::make_shared<FaissIVFFlatPass>());
|
||||
pass_list.push_back(std::make_shared<FaissIVFSQ8Pass>());
|
||||
pass_list.push_back(std::make_shared<FaissIVFSQ8HPass>());
|
||||
}
|
||||
#endif
|
||||
pass_list.push_back(std::make_shared<FallbackPass>());
|
||||
instance = std::make_shared<Optimizer>(pass_list);
|
||||
|
||||
@ -189,35 +189,37 @@ Config::ValidateConfig() {
|
||||
}
|
||||
|
||||
/* gpu resource config */
|
||||
#ifdef MILVUS_GPU_VERSION
|
||||
bool gpu_resource_enable;
|
||||
s = GetGpuResourceConfigEnable(gpu_resource_enable);
|
||||
if (!s.ok()) {
|
||||
return s;
|
||||
}
|
||||
|
||||
int64_t resource_cache_capacity;
|
||||
s = GetGpuResourceConfigCacheCapacity(resource_cache_capacity);
|
||||
if (!s.ok()) {
|
||||
return s;
|
||||
}
|
||||
#ifdef MILVUS_GPU_VERSION
|
||||
if (gpu_resource_enable) {
|
||||
int64_t resource_cache_capacity;
|
||||
s = GetGpuResourceConfigCacheCapacity(resource_cache_capacity);
|
||||
if (!s.ok()) {
|
||||
return s;
|
||||
}
|
||||
|
||||
float resource_cache_threshold;
|
||||
s = GetGpuResourceConfigCacheThreshold(resource_cache_threshold);
|
||||
if (!s.ok()) {
|
||||
return s;
|
||||
}
|
||||
float resource_cache_threshold;
|
||||
s = GetGpuResourceConfigCacheThreshold(resource_cache_threshold);
|
||||
if (!s.ok()) {
|
||||
return s;
|
||||
}
|
||||
|
||||
std::vector<int64_t> search_resources;
|
||||
s = GetGpuResourceConfigSearchResources(search_resources);
|
||||
if (!s.ok()) {
|
||||
return s;
|
||||
}
|
||||
std::vector<int64_t> search_resources;
|
||||
s = GetGpuResourceConfigSearchResources(search_resources);
|
||||
if (!s.ok()) {
|
||||
return s;
|
||||
}
|
||||
|
||||
std::vector<int64_t> index_build_resources;
|
||||
s = GetGpuResourceConfigBuildIndexResources(index_build_resources);
|
||||
if (!s.ok()) {
|
||||
return s;
|
||||
std::vector<int64_t> index_build_resources;
|
||||
s = GetGpuResourceConfigBuildIndexResources(index_build_resources);
|
||||
if (!s.ok()) {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@ -37,6 +37,16 @@ constexpr int64_t M_BYTE = 1024 * 1024;
|
||||
Status
|
||||
KnowhereResource::Initialize() {
|
||||
#ifdef MILVUS_GPU_VERSION
|
||||
Status s;
|
||||
bool enable_gpu = false;
|
||||
server::Config& config = server::Config::GetInstance();
|
||||
s = config.GetGpuResourceConfigEnable(enable_gpu);
|
||||
if (!s.ok())
|
||||
return s;
|
||||
|
||||
if (not enable_gpu)
|
||||
return Status::OK();
|
||||
|
||||
struct GpuResourceSetting {
|
||||
int64_t pinned_memory = 300 * M_BYTE;
|
||||
int64_t temp_memory = 300 * M_BYTE;
|
||||
@ -44,10 +54,8 @@ KnowhereResource::Initialize() {
|
||||
};
|
||||
using GpuResourcesArray = std::map<int64_t, GpuResourceSetting>;
|
||||
GpuResourcesArray gpu_resources;
|
||||
Status s;
|
||||
|
||||
// get build index gpu resource
|
||||
server::Config& config = server::Config::GetInstance();
|
||||
std::vector<int64_t> build_index_gpus;
|
||||
s = config.GetGpuResourceConfigBuildIndexResources(build_index_gpus);
|
||||
if (!s.ok())
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user