fix ROCm on Windows

This commit is contained in:
lone-cloud 2025-09-05 12:01:05 -07:00
parent 82614b148e
commit 141f548d91
3 changed files with 75 additions and 32 deletions

View file

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

View file

@ -86,10 +86,19 @@ const checkGpuWarnings = async (
!gpuCapabilities.rocm.supported &&
gpuInfo.hasAMD
) {
const platform = await window.electronAPI.kobold.getPlatform();
const baseMessage =
'Your binary supports ROCm and you have an AMD GPU, but ROCm runtime is not detected on your system.';
let message = baseMessage;
if (platform === 'win32') {
message +=
' On Windows, make sure ROCm is installed and its bin directory is added to your PATH so that hipInfo.exe can be found.';
}
warnings.push({
type: 'warning',
message:
'Your binary supports ROCm and you have an AMD GPU, but ROCm runtime is not detected on your system.',
message,
});
}

View file

@ -195,12 +195,28 @@ export class HardwareManager {
}
}
private async findRocminfoCommand(): Promise<string | null> {
const platform = await import('process').then((p) => p.platform);
if (platform === 'win32') {
return 'hipInfo';
} else {
return 'rocminfo';
}
}
async detectROCm(): Promise<{
supported: boolean;
devices: string[];
}> {
try {
const rocminfo = spawn('rocminfo', [], { timeout: 5000 });
const rocminfoCommand = await this.findRocminfoCommand();
if (!rocminfoCommand) {
return { supported: false, devices: [] };
}
const isWindows = rocminfoCommand.includes('hipInfo');
const rocminfo = spawn(rocminfoCommand, [], { timeout: 5000 });
let output = '';
rocminfo.stdout.on('data', (data) => {
@ -212,8 +228,25 @@ export class HardwareManager {
rocminfo.on('close', (code) => {
if (code === 0 && output.trim()) {
const devices: string[] = [];
if (isWindows) {
const lines = output.split('\n');
for (const line of lines) {
const trimmedLine = line.trim();
if (trimmedLine.startsWith('Name:')) {
const name = trimmedLine.split('Name:')[1]?.trim();
if (
name &&
!name.toLowerCase().includes('cpu') &&
!devices.includes(shortenDeviceName(name))
) {
devices.push(shortenDeviceName(name));
}
}
}
} else {
const lines = output.split('\n');
for (let i = 0; i < lines.length; i++) {
const line = lines[i];
@ -248,6 +281,7 @@ export class HardwareManager {
}
}
}
}
resolve({
supported: devices.length > 0,