diff --git a/AIEngineModule/example/test_example.cpp b/AIEngineModule/example/test_example.cpp index 0346522..a8f71eb 100644 --- a/AIEngineModule/example/test_example.cpp +++ b/AIEngineModule/example/test_example.cpp @@ -103,6 +103,8 @@ int main(int argc, char *argv[]) GPU_Config gpu; gpu.gpu_0 = true; gpu.gpu_1 = true; + gpu.gpu_2 = true; + gpu.gpu_3 = true; AI_Factory->InitALLAIModle(gpu); std::shared_ptr BOE_Edge_Detect = AI_Factory->BOE_Edge_Detect; diff --git a/AIEngineModule/include_base/AI_Factory.h b/AIEngineModule/include_base/AI_Factory.h index 2fab0e2..4b00fd0 100644 --- a/AIEngineModule/include_base/AI_Factory.h +++ b/AIEngineModule/include_base/AI_Factory.h @@ -31,10 +31,14 @@ struct GPU_Config { bool gpu_0; bool gpu_1; + bool gpu_2; + bool gpu_3; GPU_Config() { gpu_0 = true; gpu_1 = true; + gpu_2 = true; + gpu_3 = true; } int GetNum() { @@ -47,12 +51,22 @@ struct GPU_Config { num++; } + if (gpu_2) + { + num++; + } + if (gpu_3) + { + num++; + } return num; } void copy(GPU_Config tem) { this->gpu_0 = tem.gpu_0; this->gpu_1 = tem.gpu_1; + this->gpu_2 = tem.gpu_2; + this->gpu_3 = tem.gpu_3; } }; diff --git a/AIEngineModule/src/AIModel_Impl.cpp b/AIEngineModule/src/AIModel_Impl.cpp index edd402c..d6e392d 100644 --- a/AIEngineModule/src/AIModel_Impl.cpp +++ b/AIEngineModule/src/AIModel_Impl.cpp @@ -48,22 +48,22 @@ int AIModel_Impl::Init(AIModelRun_Config config) if (m_modelRun_Config.gpuconfig.gpu_0) { re = LoadEngine(0); - // 加载失败 - if (re != 0) - { - } } if (m_modelRun_Config.gpuconfig.gpu_1) { re = LoadEngine(1); - // 加载失败 - if (re != 0) - { - } + } + if (m_modelRun_Config.gpuconfig.gpu_2) + { + re = LoadEngine(2); + } + if (m_modelRun_Config.gpuconfig.gpu_3) + { + re = LoadEngine(3); } int nGPUNum = m_GPU_Engine.size(); // 模型载入失败 - if (nGPUNum <= 0 || nGPUNum > 2) + if (nGPUNum <= 0 || nGPUNum > 4) { printf(" %s model Init error \n", m_modelRun_Config.strName.c_str()); return 2; @@ -113,10 +113,14 @@ int AIModel_Impl::Init(AIModelRun_Config config) // 生产推理用的 参数信息 if (m_GPU_Engine.size() > 1) { - if (m_GPU_Engine.at(0)->cudaSteams.size() != m_GPU_Engine.at(1)->cudaSteams.size()) + size_t firstStreamNum = m_GPU_Engine.at(0)->cudaSteams.size(); + for (size_t i = 1; i < m_GPU_Engine.size(); i++) { - printf(" %s model Init error \n", m_modelRun_Config.strName.c_str()); - return 3; + if (m_GPU_Engine.at(i)->cudaSteams.size() != firstStreamNum) + { + printf(" %s model Init error \n", m_modelRun_Config.strName.c_str()); + return 3; + } } } if (streamNum <= 0) diff --git a/AlgorithmModule/src/ALLImgCheckAnalysisy.cpp b/AlgorithmModule/src/ALLImgCheckAnalysisy.cpp index 3ed5e0b..f973d06 100644 --- a/AlgorithmModule/src/ALLImgCheckAnalysisy.cpp +++ b/AlgorithmModule/src/ALLImgCheckAnalysisy.cpp @@ -302,6 +302,8 @@ int ALLImgCheckAnalysisy::InitAIFactory() GPU_Config gpu; gpu.gpu_0 = true; gpu.gpu_1 = true; + gpu.gpu_2 = true; + gpu.gpu_3 = true; AI_Factory->InitALLAIModle(gpu); return 0; diff --git a/example/SystemCommonDefine.h b/example/SystemCommonDefine.h index 773cce8..a1e3ee0 100644 --- a/example/SystemCommonDefine.h +++ b/example/SystemCommonDefine.h @@ -60,7 +60,7 @@ enum CHECKIMGTRUNTYP_ // url长度 #define MAX_ULR_LEN 256 -#define MAX_GPU_NUM 2 +#define MAX_GPU_NUM 4 // ncnn 行人检测 跟踪 检测最大 线程个数 #define MAX_PERSONTRACKER_THREAD_NUM 4