From edc2531683329966d503ba79bcea380105f0f81c Mon Sep 17 00:00:00 2001 From: vansangpfiev Date: Tue, 17 Dec 2024 17:11:20 +0700 Subject: [PATCH 1/4] fix: check cpu info size --- engine/utils/hardware/cpu_info.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/engine/utils/hardware/cpu_info.h b/engine/utils/hardware/cpu_info.h index 4c2cb3027..4395cc8dd 100644 --- a/engine/utils/hardware/cpu_info.h +++ b/engine/utils/hardware/cpu_info.h @@ -10,7 +10,10 @@ namespace cortex::hw { inline CPU GetCPUInfo() { - auto cpu = hwinfo::getAllCPUs()[0]; + auto res = hwinfo::getAllCPUs(); + if (res.empty()) + return CPU{}; + auto cpu = res[0]; cortex::cpuid::CpuInfo inst; return CPU{.cores = cpu.numPhysicalCores(), .arch = std::string(GetArch()), From 7c2526d368890f8f75f6020bab9f36b7a0de2d37 Mon Sep 17 00:00:00 2001 From: vansangpfiev Date: Tue, 17 Dec 2024 17:24:24 +0700 Subject: [PATCH 2/4] fix: sort gpus --- engine/services/hardware_service.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engine/services/hardware_service.cc b/engine/services/hardware_service.cc index ca1ea4cc6..ca2bd8ed9 100644 --- a/engine/services/hardware_service.cc +++ b/engine/services/hardware_service.cc @@ -235,8 +235,8 @@ bool HardwareService::SetActivateHardwareConfig( activated_ids.push_back(std::pair(e.software_id, e.priority)); } } - std::sort(activated_ids.begin(), activated_ids.end()); - std::sort(ahc_gpus.begin(), ahc_gpus.end()); + std::sort(activated_ids.begin(), activated_ids.end(), + [](auto& p1, auto& p2) { return p1.second < p2.second; }); if (ahc_gpus.size() != activated_ids.size()) { need_update = true; } else { From 4cf1951e631333fd4ffb245608f47656946f2216 Mon Sep 17 00:00:00 2001 From: vansangpfiev Date: Wed, 18 Dec 2024 13:19:46 +0700 Subject: [PATCH 3/4] chore: add log for cpu instructions --- engine/cli/commands/model_status_cmd.cc | 2 +- engine/services/engine_service.cc | 2 ++ engine/utils/github_release_utils.h | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/engine/cli/commands/model_status_cmd.cc b/engine/cli/commands/model_status_cmd.cc index cd9f3034d..e467e4353 100644 --- a/engine/cli/commands/model_status_cmd.cc +++ b/engine/cli/commands/model_status_cmd.cc @@ -25,7 +25,7 @@ bool ModelStatusCmd::IsLoaded(const std::string& host, int port, auto res = curl_utils::SimpleGetJson(url.ToFullPath()); if (res.has_error()) { auto root = json_helper::ParseJsonString(res.error()); - CLI_LOG(root["message"].asString()); + CTL_WRN(root["message"].asString()); return false; } diff --git a/engine/services/engine_service.cc b/engine/services/engine_service.cc index 1f3e4d81c..6650ce5d5 100644 --- a/engine/services/engine_service.cc +++ b/engine/services/engine_service.cc @@ -17,6 +17,7 @@ #include "utils/semantic_version_utils.h" #include "utils/system_info_utils.h" #include "utils/url_parser.h" +#include "utils/cpuid/cpu_info.h" namespace { std::string GetSuitableCudaVersion(const std::string& engine, @@ -691,6 +692,7 @@ cpp::result EngineService::LoadEngine( // End hard code CTL_INF("Loading engine: " << ne); + CTL_INF("CPU Info: " << cortex::cpuid::CpuInfo().to_string()); auto engine_dir_path_res = GetEngineDirPath(ne); if (engine_dir_path_res.has_error()) { diff --git a/engine/utils/github_release_utils.h b/engine/utils/github_release_utils.h index be97cb37c..72d7687f6 100644 --- a/engine/utils/github_release_utils.h +++ b/engine/utils/github_release_utils.h @@ -194,7 +194,7 @@ inline cpp::result GetReleaseByVersion( .pathParams = path_params, }; - CTL_DBG("GetReleaseByVersion: " << url.ToFullPath()); + // CTL_DBG("GetReleaseByVersion: " << url.ToFullPath()); auto result = curl_utils::SimpleGetJson(url_parser::FromUrl(url), kCurlGetTimeout); From d1f4ca821e0cd93b4841aba9ab329198e8c4e227 Mon Sep 17 00:00:00 2001 From: vansangpfiev Date: Wed, 18 Dec 2024 15:19:35 +0700 Subject: [PATCH 4/4] fix: add guard --- engine/services/engine_service.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/engine/services/engine_service.cc b/engine/services/engine_service.cc index 6650ce5d5..0e074d11e 100644 --- a/engine/services/engine_service.cc +++ b/engine/services/engine_service.cc @@ -8,6 +8,7 @@ #include "database/engines.h" #include "extensions/remote-engine/remote_engine.h" #include "utils/archive_utils.h" +#include "utils/cpuid/cpu_info.h" #include "utils/engine_constants.h" #include "utils/engine_matcher_utils.h" #include "utils/file_manager_utils.h" @@ -17,7 +18,6 @@ #include "utils/semantic_version_utils.h" #include "utils/system_info_utils.h" #include "utils/url_parser.h" -#include "utils/cpuid/cpu_info.h" namespace { std::string GetSuitableCudaVersion(const std::string& engine, @@ -692,7 +692,9 @@ cpp::result EngineService::LoadEngine( // End hard code CTL_INF("Loading engine: " << ne); +#if defined(_WIN32) || defined(_WIN64) || defined(__linux__) CTL_INF("CPU Info: " << cortex::cpuid::CpuInfo().to_string()); +#endif auto engine_dir_path_res = GetEngineDirPath(ne); if (engine_dir_path_res.has_error()) {