From ddf42c41db64059ab0cd14476fa3316127945da4 Mon Sep 17 00:00:00 2001 From: Egor Date: Fri, 26 Sep 2025 14:26:39 -0700 Subject: [PATCH] re-fix clblast for windows --- .prettierrc | 3 +- src/main/modules/hardware.ts | 26 +++++++--------- src/main/modules/koboldcpp/backend.ts | 5 ++- src/utils/node/gpu.ts | 44 --------------------------- 4 files changed, 17 insertions(+), 61 deletions(-) diff --git a/.prettierrc b/.prettierrc index 7225824..8f88ab3 100644 --- a/.prettierrc +++ b/.prettierrc @@ -4,5 +4,6 @@ "singleQuote": true, "printWidth": 80, "tabWidth": 2, - "useTabs": false + "useTabs": false, + "endOfLine": "lf" } diff --git a/src/main/modules/hardware.ts b/src/main/modules/hardware.ts index e0c63e1..a80064d 100644 --- a/src/main/modules/hardware.ts +++ b/src/main/modules/hardware.ts @@ -5,7 +5,7 @@ import { memLayout as siMemLayout, } from 'systeminformation'; import { safeExecute } from '@/utils/node/logging'; -import { getGPUData, detectGPUViaSI } from '@/utils/node/gpu'; +import { getGPUData } from '@/utils/node/gpu'; import type { CPUCapabilities, GPUCapabilities, @@ -63,13 +63,10 @@ export async function detectGPU() { return basicGPUInfoCache; } - const result = await safeExecute(async () => { - if (platform === 'linux') { - return detectLinuxGPUViaVulkan(); - } - - return detectGPUViaSI(); - }, 'GPU detection failed'); + const result = await safeExecute( + () => detectLinuxGPUViaVulkan(), + 'GPU detection failed' + ); const fallbackGPUInfo = { hasAMD: false, @@ -396,7 +393,10 @@ function findComputeUnitsInClInfo(lines: string[], startIndex: number) { ) { const nextLine = lines[j].trim(); if (nextLine.includes('Max compute units')) { - const units = nextLine.split('Max compute units')[1]?.trim(); + const units = nextLine + .split('Max compute units')[1] + ?.trim() + .replace(/^:?\s*/, ''); return units ? parseInt(units, 10) : 0; } } @@ -410,13 +410,9 @@ async function detectCLBlast() { const { stdout } = await execa('clinfo', [], COMMON_EXEC_OPTIONS); if (stdout.trim()) { - const devices = parseClInfoOutput(stdout); - - const version = 'Available'; - return { - devices, - version, + devices: parseClInfoOutput(stdout), + version: 'Available', }; } diff --git a/src/main/modules/koboldcpp/backend.ts b/src/main/modules/koboldcpp/backend.ts index 9b2818d..fb38659 100644 --- a/src/main/modules/koboldcpp/backend.ts +++ b/src/main/modules/koboldcpp/backend.ts @@ -142,7 +142,10 @@ export async function getAvailableBackends(includeDisabled = false) { } if (backendSupport.clblast) { - const isSupported = hardwareCapabilities.clblast.devices.length > 0; + const discreteDevices = hardwareCapabilities.clblast.devices.filter( + (device) => typeof device === 'string' || !device.isIntegrated + ); + const isSupported = discreteDevices.length > 0; if (isSupported || includeDisabled) { backends.push({ value: 'clblast', diff --git a/src/utils/node/gpu.ts b/src/utils/node/gpu.ts index a695cd2..2c8df39 100644 --- a/src/utils/node/gpu.ts +++ b/src/utils/node/gpu.ts @@ -2,7 +2,6 @@ import { readFile, readdir } from 'fs/promises'; import { join } from 'path'; import { platform } from 'process'; import { graphics as siGraphics } from 'systeminformation'; -import { formatDeviceName } from '../format'; interface CachedGPUInfo { devicePath: string; @@ -215,46 +214,3 @@ export function isDiscreteBusAddress(busAddress?: string) { return false; } - -export async function detectGPUViaSI() { - const graphics = await siGraphics(); - - let hasAMD = false; - let hasNVIDIA = false; - const gpuInfo: string[] = []; - - const discreteControllers = graphics.controllers.filter((controller) => { - if (platform === 'linux' && controller.busAddress) { - return isDiscreteBusAddress(controller.busAddress); - } - - if (platform === 'win32') { - return controller.vram && controller.vram >= 1024; - } - - return false; - }); - - for (const controller of discreteControllers) { - if ( - controller.vendor?.toLowerCase().includes('amd') || - controller.vendor?.toLowerCase().includes('ati') - ) { - hasAMD = true; - } - - if (controller.vendor?.toLowerCase().includes('nvidia')) { - hasNVIDIA = true; - } - - if (controller.model) { - gpuInfo.push(formatDeviceName(controller.model)); - } - } - - return { - hasAMD, - hasNVIDIA, - gpuInfo: gpuInfo.length > 0 ? gpuInfo : [], - }; -}