fix CUDA detection?

This commit is contained in:
Egor 2025-10-21 21:35:16 -07:00
parent 3e87a2c3e2
commit 978d8db455
4 changed files with 24 additions and 41 deletions

View file

@ -1,7 +1,7 @@
{
"name": "gerbil",
"productName": "Gerbil",
"version": "1.7.0",
"version": "1.7.1",
"description": "Run Large Language Models locally",
"main": "out/main/index.js",
"homepage": "./",

View file

@ -1,6 +1,6 @@
import { useEffect, useState, useCallback, useMemo } from 'react';
import type { BackendOption, BackendSupport } from '@/types';
import { CPUCapabilities, GPUDevice } from '@/types/hardware';
import type { BackendOption, BackendSupport } from '@/types';
export interface Warning {
type: 'warning' | 'info';
@ -61,7 +61,7 @@ const checkGpuWarnings = async (
backendSupport: BackendSupport,
gpuCapabilities: GpuCapabilities,
gpuInfo: GpuInfo
): Promise<Warning[]> => {
) => {
const warnings: Warning[] = [];
if (

View file

@ -126,7 +126,11 @@ async function detectVulkan() {
async function detectCUDA() {
try {
const { stdout } = await execa('nvidia-smi', [], COMMON_EXEC_OPTIONS);
const { stdout } = await execa(
'nvidia-smi',
['--query-gpu=name,driver_version,cuda_version', '--format=csv,noheader'],
COMMON_EXEC_OPTIONS
);
if (stdout.trim()) {
const errorPatterns = [
@ -145,33 +149,21 @@ async function detectCUDA() {
return { devices: [] } as const;
}
const lines = stdout.split('\n').filter((line) => line.trim());
const devices: string[] = [];
let cudaVersion: string | undefined;
let driverVersion: string | undefined;
let cudaVersion: string | undefined;
const cudaMatch = stdout.match(/CUDA Version:\s*(\d+\.\d+)/);
if (cudaMatch) {
cudaVersion = cudaMatch[1];
}
const driverMatch = stdout.match(
/Driver Version:\s*(\d+\.\d+(?:\.\d+)?)/
);
if (driverMatch) {
driverVersion = driverMatch[1];
}
const gpuNameMatch = stdout.match(/\|\s+\d+\s+([^|]+)\s+On\s+\|/g);
if (gpuNameMatch) {
for (const match of gpuNameMatch) {
const name = match
.replace(/\|\s+\d+\s+([^|]+)\s+On\s+\|/, '$1')
.trim();
if (name) {
devices.push(formatDeviceName(name));
}
for (const line of lines) {
const [name, driver, cuda] = line.split(',').map((s) => s.trim());
if (name) {
devices.push(formatDeviceName(name));
}
if (driver && !driverVersion) {
driverVersion = driver;
}
if (cuda && !cudaVersion) {
cudaVersion = cuda;
}
}

View file

@ -1376,12 +1376,12 @@ __metadata:
languageName: node
linkType: hard
"@types/node@npm:*":
version: 24.9.0
resolution: "@types/node@npm:24.9.0"
"@types/node@npm:*, @types/node@npm:^24.9.1":
version: 24.9.1
resolution: "@types/node@npm:24.9.1"
dependencies:
undici-types: "npm:~7.16.0"
checksum: 10c0/c0129572f2c1528d2d1b7f4ebdbc3c4b40273964d40786c8be3596e7482394ed4882676b2a44362d4b1da5bac0274fdf2cae11dce3d76319cadac541fd76e531
checksum: 10c0/c52f8168080ef9a7c3dc23d8ac6061fab5371aad89231a0f6f4c075869bc3de7e89b075b1f3e3171d9e5143d0dda1807c3dab8e32eac6d68f02e7480e7e78576
languageName: node
linkType: hard
@ -1394,15 +1394,6 @@ __metadata:
languageName: node
linkType: hard
"@types/node@npm:^24.9.1":
version: 24.9.1
resolution: "@types/node@npm:24.9.1"
dependencies:
undici-types: "npm:~7.16.0"
checksum: 10c0/c52f8168080ef9a7c3dc23d8ac6061fab5371aad89231a0f6f4c075869bc3de7e89b075b1f3e3171d9e5143d0dda1807c3dab8e32eac6d68f02e7480e7e78576
languageName: node
linkType: hard
"@types/plist@npm:^3.0.1":
version: 3.0.5
resolution: "@types/plist@npm:3.0.5"