Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit 3e8572d

Browse files
fix: ignore compute_cap if not present (#1866)
* fix: ignore compute_cap if not present * fix: correct gpu info * fix: remove check for toolkit version --------- Co-authored-by: vansangpfiev <sang@jan.ai>
1 parent 5d355c8 commit 3e8572d

File tree

4 files changed

+25
-23
lines changed

4 files changed

+25
-23
lines changed

engine/services/engine_service.cc

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -404,17 +404,6 @@ cpp::result<bool, std::string> EngineService::DownloadCuda(
404404
auto suitable_toolkit_version =
405405
GetSuitableCudaVersion(engine, hw_inf_.cuda_driver_version);
406406

407-
// compare cuda driver version with cuda toolkit version
408-
// cuda driver version should be greater than toolkit version to ensure compatibility
409-
if (semantic_version_utils::CompareSemanticVersion(
410-
hw_inf_.cuda_driver_version, suitable_toolkit_version) < 0) {
411-
CTL_ERR("Your Cuda driver version "
412-
<< hw_inf_.cuda_driver_version
413-
<< " is not compatible with cuda toolkit version "
414-
<< suitable_toolkit_version);
415-
return cpp::fail("Cuda driver is not compatible with cuda toolkit");
416-
}
417-
418407
auto url_obj = url_parser::Url{
419408
.protocol = "https",
420409
.host = jan_host,

engine/utils/hardware/gpu_info.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ inline std::vector<GPU> GetGPUInfo() {
1717

1818
for (size_t i = 0; i < nvidia_gpus.size(); i++) {
1919
for (size_t j = 0; j < vulkan_gpus.size(); j++) {
20-
if (nvidia_gpus[i].uuid == vulkan_gpus[j].uuid) {
20+
if (nvidia_gpus[i].uuid.find(vulkan_gpus[j].uuid) != std::string::npos) {
2121
vulkan_gpus[j].version =
2222
nvidia_gpus[0].cuda_driver_version.value_or("unknown");
2323
vulkan_gpus[j].add_info = NvidiaAddInfo{

engine/utils/system_info_utils.cc

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -108,26 +108,32 @@ std::vector<GpuInfo> GetGpuInfoList() {
108108
auto [driver_version, cuda_version] = GetDriverAndCudaVersion();
109109
if (driver_version.empty() || cuda_version.empty())
110110
return gpuInfoList;
111-
111+
bool need_fallback = false;
112112
CommandExecutor cmd(kGpuQueryCommand);
113113
auto output = cmd.execute();
114+
if (output.find("NVIDIA") == std::string::npos) {
115+
need_fallback = true;
116+
output = CommandExecutor(kGpuQueryCommandFb).execute();
117+
}
114118

115-
const std::regex gpu_info_reg(kGpuInfoRegex);
119+
std::string rg = need_fallback ? kGpuInfoRegexFb : kGpuInfoRegex;
120+
const std::regex gpu_info_reg(rg);
116121
std::smatch match;
117122
std::string::const_iterator search_start(output.cbegin());
123+
int rg_count = need_fallback ? 5 : 6;
118124

119125
while (
120126
std::regex_search(search_start, output.cend(), match, gpu_info_reg)) {
121127
GpuInfo gpuInfo = {
122-
match[1].str(), // id
123-
match[2].str(), // vram_total
124-
match[3].str(), // vram_free
125-
match[4].str(), // name
126-
GetGpuArch(match[4].str()), // arch
127-
driver_version, // driver_version
128-
cuda_version, // cuda_driver_version
129-
match[5].str(), // compute_cap
130-
match[6].str() // uuid
128+
match[1].str(), // id
129+
match[2].str(), // vram_total
130+
match[3].str(), // vram_free
131+
match[4].str(), // name
132+
GetGpuArch(match[4].str()), // arch
133+
driver_version, // driver_version
134+
cuda_version, // cuda_driver_version
135+
need_fallback ? "0" : match[5].str(), // compute_cap
136+
match[rg_count].str() // uuid
131137
};
132138
gpuInfoList.push_back(gpuInfo);
133139
search_start = match.suffix().first;

engine/utils/system_info_utils.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ constexpr static auto kGpuQueryCommand{
2525
constexpr static auto kGpuInfoRegex{
2626
R"((\d+),\s*(\d+),\s*(\d+),\s*([^,]+),\s*([\d\.]+),\s*([^\n,]+))"};
2727

28+
constexpr static auto kGpuQueryCommandFb{
29+
"nvidia-smi "
30+
"--query-gpu=index,memory.total,memory.free,name,uuid "
31+
"--format=csv,noheader,nounits"};
32+
constexpr static auto kGpuInfoRegexFb{
33+
R"((\d+),\s*(\d+),\s*(\d+),\s*([^,]+),\s*([^\n,]+))"};
34+
2835
struct SystemInfo {
2936
explicit SystemInfo(std::string os, std::string arch)
3037
: os(std::move(os)), arch(std::move(arch)) {}

0 commit comments

Comments
 (0)