mirror of
https://github.com/lone-cloud/gerbil
synced 2026-06-03 09:33:10 -07:00
fix ROCm on Windows
This commit is contained in:
parent
82614b148e
commit
141f548d91
3 changed files with 75 additions and 32 deletions
|
|
@ -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": "./",
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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,41 +228,59 @@ export class HardwareManager {
|
|||
rocminfo.on('close', (code) => {
|
||||
if (code === 0 && output.trim()) {
|
||||
const devices: string[] = [];
|
||||
const lines = output.split('\n');
|
||||
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
const line = lines[i];
|
||||
if (isWindows) {
|
||||
const lines = output.split('\n');
|
||||
|
||||
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++
|
||||
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))
|
||||
) {
|
||||
if (lines[searchIndex].includes('Device Type:')) {
|
||||
deviceType =
|
||||
lines[searchIndex].split('Device Type:')[1]?.trim() ||
|
||||
'';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (deviceType !== 'CPU') {
|
||||
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({
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue