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", "name": "gerbil",
"productName": "Gerbil", "productName": "Gerbil",
"version": "1.0.0", "version": "1.0.1",
"description": "Run Large Language Models locally", "description": "Run Large Language Models locally",
"main": "out/main/index.js", "main": "out/main/index.js",
"homepage": "./", "homepage": "./",

View file

@ -86,10 +86,19 @@ const checkGpuWarnings = async (
!gpuCapabilities.rocm.supported && !gpuCapabilities.rocm.supported &&
gpuInfo.hasAMD 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({ warnings.push({
type: 'warning', type: 'warning',
message: message,
'Your binary supports ROCm and you have an AMD GPU, but ROCm runtime is not detected on your system.',
}); });
} }

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<{ async detectROCm(): Promise<{
supported: boolean; supported: boolean;
devices: string[]; devices: string[];
}> { }> {
try { 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 = ''; let output = '';
rocminfo.stdout.on('data', (data) => { rocminfo.stdout.on('data', (data) => {
@ -212,41 +228,59 @@ export class HardwareManager {
rocminfo.on('close', (code) => { rocminfo.on('close', (code) => {
if (code === 0 && output.trim()) { if (code === 0 && output.trim()) {
const devices: string[] = []; const devices: string[] = [];
const lines = output.split('\n');
for (let i = 0; i < lines.length; i++) { if (isWindows) {
const line = lines[i]; const lines = output.split('\n');
if (line.includes('Marketing Name:')) { for (const line of lines) {
const name = line.split('Marketing Name:')[1]?.trim(); const trimmedLine = line.trim();
if (name) { if (trimmedLine.startsWith('Name:')) {
let deviceType = ''; const name = trimmedLine.split('Name:')[1]?.trim();
if (
const searchRangeLines = 20; name &&
const searchStartIndex = Math.max(0, i - searchRangeLines); !name.toLowerCase().includes('cpu') &&
const searchEndIndex = Math.min( !devices.includes(shortenDeviceName(name))
lines.length,
i + searchRangeLines
);
for (
let searchIndex = searchStartIndex;
searchIndex < searchEndIndex;
searchIndex++
) { ) {
if (lines[searchIndex].includes('Device Type:')) {
deviceType =
lines[searchIndex].split('Device Type:')[1]?.trim() ||
'';
break;
}
}
if (deviceType !== 'CPU') {
devices.push(shortenDeviceName(name)); devices.push(shortenDeviceName(name));
} }
} }
} }
} else {
const lines = output.split('\n');
for (let i = 0; i < lines.length; i++) {
const line = lines[i];
if (line.includes('Marketing Name:')) {
const name = line.split('Marketing Name:')[1]?.trim();
if (name) {
let deviceType = '';
const searchRangeLines = 20;
const searchStartIndex = Math.max(0, i - searchRangeLines);
const searchEndIndex = Math.min(
lines.length,
i + searchRangeLines
);
for (
let searchIndex = searchStartIndex;
searchIndex < searchEndIndex;
searchIndex++
) {
if (lines[searchIndex].includes('Device Type:')) {
deviceType =
lines[searchIndex].split('Device Type:')[1]?.trim() ||
'';
break;
}
}
if (deviceType !== 'CPU') {
devices.push(shortenDeviceName(name));
}
}
}
}
} }
resolve({ resolve({