mirror of
https://github.com/lone-cloud/gerbil
synced 2026-06-03 19:54:44 -07:00
re-fix clblast for windows
This commit is contained in:
parent
caaf2427d3
commit
ddf42c41db
4 changed files with 17 additions and 61 deletions
|
|
@ -4,5 +4,6 @@
|
||||||
"singleQuote": true,
|
"singleQuote": true,
|
||||||
"printWidth": 80,
|
"printWidth": 80,
|
||||||
"tabWidth": 2,
|
"tabWidth": 2,
|
||||||
"useTabs": false
|
"useTabs": false,
|
||||||
|
"endOfLine": "lf"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import {
|
||||||
memLayout as siMemLayout,
|
memLayout as siMemLayout,
|
||||||
} from 'systeminformation';
|
} from 'systeminformation';
|
||||||
import { safeExecute } from '@/utils/node/logging';
|
import { safeExecute } from '@/utils/node/logging';
|
||||||
import { getGPUData, detectGPUViaSI } from '@/utils/node/gpu';
|
import { getGPUData } from '@/utils/node/gpu';
|
||||||
import type {
|
import type {
|
||||||
CPUCapabilities,
|
CPUCapabilities,
|
||||||
GPUCapabilities,
|
GPUCapabilities,
|
||||||
|
|
@ -63,13 +63,10 @@ export async function detectGPU() {
|
||||||
return basicGPUInfoCache;
|
return basicGPUInfoCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await safeExecute(async () => {
|
const result = await safeExecute(
|
||||||
if (platform === 'linux') {
|
() => detectLinuxGPUViaVulkan(),
|
||||||
return detectLinuxGPUViaVulkan();
|
'GPU detection failed'
|
||||||
}
|
);
|
||||||
|
|
||||||
return detectGPUViaSI();
|
|
||||||
}, 'GPU detection failed');
|
|
||||||
|
|
||||||
const fallbackGPUInfo = {
|
const fallbackGPUInfo = {
|
||||||
hasAMD: false,
|
hasAMD: false,
|
||||||
|
|
@ -396,7 +393,10 @@ function findComputeUnitsInClInfo(lines: string[], startIndex: number) {
|
||||||
) {
|
) {
|
||||||
const nextLine = lines[j].trim();
|
const nextLine = lines[j].trim();
|
||||||
if (nextLine.includes('Max compute units')) {
|
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;
|
return units ? parseInt(units, 10) : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -410,13 +410,9 @@ async function detectCLBlast() {
|
||||||
const { stdout } = await execa('clinfo', [], COMMON_EXEC_OPTIONS);
|
const { stdout } = await execa('clinfo', [], COMMON_EXEC_OPTIONS);
|
||||||
|
|
||||||
if (stdout.trim()) {
|
if (stdout.trim()) {
|
||||||
const devices = parseClInfoOutput(stdout);
|
|
||||||
|
|
||||||
const version = 'Available';
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
devices,
|
devices: parseClInfoOutput(stdout),
|
||||||
version,
|
version: 'Available',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -142,7 +142,10 @@ export async function getAvailableBackends(includeDisabled = false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (backendSupport.clblast) {
|
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) {
|
if (isSupported || includeDisabled) {
|
||||||
backends.push({
|
backends.push({
|
||||||
value: 'clblast',
|
value: 'clblast',
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import { readFile, readdir } from 'fs/promises';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { platform } from 'process';
|
import { platform } from 'process';
|
||||||
import { graphics as siGraphics } from 'systeminformation';
|
import { graphics as siGraphics } from 'systeminformation';
|
||||||
import { formatDeviceName } from '../format';
|
|
||||||
|
|
||||||
interface CachedGPUInfo {
|
interface CachedGPUInfo {
|
||||||
devicePath: string;
|
devicePath: string;
|
||||||
|
|
@ -215,46 +214,3 @@ export function isDiscreteBusAddress(busAddress?: string) {
|
||||||
|
|
||||||
return false;
|
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 : [],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue