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 { 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()),