From ff22c08f01b6d780e23876df6bc7cbdd62ec1d36 Mon Sep 17 00:00:00 2001 From: scorpion-26 Date: Wed, 23 Aug 2023 15:07:45 +0200 Subject: [PATCH] Disable Nvidia on nvml init failure https://github.com/scorpion-26/gBar/issues/39 --- src/NvidiaGPU.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/NvidiaGPU.h b/src/NvidiaGPU.h index a2b0cbd..8952cbe 100644 --- a/src/NvidiaGPU.h +++ b/src/NvidiaGPU.h @@ -28,7 +28,12 @@ namespace NvidiaGPU typedef int (*PFN_nvmlInit)(); auto nvmlInit = (PFN_nvmlInit)dlsym(nvmldl, "nvmlInit"); int res = nvmlInit(); - ASSERT(res == 0, "Failed initializing nvml (Error: " << res << ")!"); + if (res != 0) + { + LOG("Failed initializing nvml (Error: " << res << "), disabling Nvidia GPU"); + RuntimeConfig::Get().hasNvidia = false; + return; + } // Get GPU handle typedef int (*PFN_nvmlDeviceGetHandle)(uint32_t, void**);