提交 da99a9e1 编写于 作者: P peng.xu

Merge branch 'branch-0.4.0' into 'branch-0.4.0'

fix build index error

See merge request megasearch/milvus!562

Former-commit-id: 3f42a54ffa04c2f8c53ff6228e982fac8281b4fd
......@@ -60,18 +60,7 @@ load_simple_config() {
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), io);
auto pinned_memory = 300;
auto temp_memory = 300;
auto resource_num = 2;
pinned_memory = 1024 * 1024 * pinned_memory;
temp_memory = 1024 * 1024 * temp_memory;
knowhere::FaissGpuResourceMgr::GetInstance().InitDevice(gpu_id,
pinned_memory,
temp_memory,
resource_num);
}
knowhere::FaissGpuResourceMgr::GetInstance().InitResource();
}
}
......
......@@ -20,7 +20,7 @@
#include <unistd.h>
#include <string.h>
#include <src/scheduler/SchedInst.h>
#include "knowhere/index/vector_index/gpu_ivf.h"
#include "wrapper/knowhere/KnowhereResource.h"
#include "metrics/Metrics.h"
#include "DBWrapper.h"
......@@ -250,6 +250,7 @@ Server::LoadConfig() {
void
Server::StartService() {
engine::KnowhereResource::Initialize();
engine::StartSchedulerService();
DBWrapper::GetInstance().StartService();
grpc::GrpcMilvusServer::StartService();
......@@ -260,7 +261,7 @@ Server::StopService() {
grpc::GrpcMilvusServer::StopService();
DBWrapper::GetInstance().StopService();
engine::StopSchedulerService();
knowhere::FaissGpuResourceMgr::GetInstance().Free(); // free gpu resource.
engine::KnowhereResource::Finalize();
}
}
......
////////////////////////////////////////////////////////////////////////////////
// Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved
// Unauthorized copying of this file, via any medium is strictly prohibited.
// Proprietary and confidential.
////////////////////////////////////////////////////////////////////////////////
#include "KnowhereResource.h"
#include "server/ServerConfig.h"
#include <map>
namespace zilliz {
namespace milvus {
namespace engine {
constexpr int64_t M_BYTE = 1024 * 1024;
ErrorCode KnowhereResource::Initialize() {
struct GpuResourceSetting {
int64_t pinned_memory = 300*M_BYTE;
int64_t temp_memory = 300*M_BYTE;
int64_t resource_num = 2;
};
using GpuResourcesArray = std::map<int64_t , GpuResourceSetting>;
GpuResourcesArray gpu_resources;
//get build index gpu resource
server::ServerConfig& root_config = server::ServerConfig::GetInstance();
server::ConfigNode& db_config = root_config.GetConfig(server::CONFIG_DB);
int32_t build_index_gpu = db_config.GetInt32Value(server::CONFIG_DB_BUILD_INDEX_GPU, 0);
gpu_resources.insert(std::make_pair(build_index_gpu, GpuResourceSetting()));
//get search gpu resource
server::ConfigNode& res_config = root_config.GetConfig(server::CONFIG_RESOURCE);
auto resources = res_config.GetSequence("resources");
std::set<uint64_t> gpu_ids;
for (auto &resource : resources) {
if (resource.length() < 4 || resource.substr(0, 3) != "gpu") {
// invalid
continue;
}
auto gpu_id = std::stoi(resource.substr(3));
gpu_resources.insert(std::make_pair(gpu_id, GpuResourceSetting()));
}
//init gpu resources
for(auto iter = gpu_resources.begin(); iter != gpu_resources.end(); ++iter) {
knowhere::FaissGpuResourceMgr::GetInstance().InitDevice(iter->first,
iter->second.pinned_memory,
iter->second.temp_memory,
iter->second.resource_num);
}
return KNOWHERE_SUCCESS;
}
ErrorCode KnowhereResource::Finalize() {
knowhere::FaissGpuResourceMgr::GetInstance().Free(); // free gpu resource.
return KNOWHERE_SUCCESS;
}
}
}
}
\ No newline at end of file
////////////////////////////////////////////////////////////////////////////////
// Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved
// Unauthorized copying of this file, via any medium is strictly prohibited.
// Proprietary and confidential.
////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "utils/Error.h"
#include "knowhere/index/vector_index/gpu_ivf.h"
namespace zilliz {
namespace milvus {
namespace engine {
class KnowhereResource {
public:
static ErrorCode Initialize();
static ErrorCode Finalize();
};
}
}
}
include_directories("${CUDA_TOOLKIT_ROOT_DIR}/include")
link_directories("${CUDA_TOOLKIT_ROOT_DIR}/lib64")
aux_source_directory(${MILVUS_ENGINE_SRC}/wrapper/knowhere knowhere_src)
set(knowhere_src
${MILVUS_ENGINE_SRC}/wrapper/knowhere/data_transfer.cpp
${MILVUS_ENGINE_SRC}/wrapper/knowhere/vec_impl.cpp
${MILVUS_ENGINE_SRC}/wrapper/knowhere/vec_index.cpp)
set(helper
utils.cpp)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册