feat: use Metal-GPU binary for macOS arm64 local inference
macOS Apple Silicon (darwin-arm64) now downloads the Metal-accelerated sd-cli from our own GitHub release instead of the stock leejet build, enabling significantly faster local image generation on M1/M2/M3/M4. All other platforms continue to use the leejet upstream release. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
8cf83b1b45
commit
6011fcb0fd
1 changed files with 41 additions and 22 deletions
|
|
@ -156,11 +156,27 @@ async function getBinaryStatus() {
|
||||||
return { exists, path: BINARY_PATH };
|
return { exists, path: BINARY_PATH };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Metal-enabled binaries hosted on our own release (macOS arm64 only).
|
||||||
|
// Other platforms fall back to the stock leejet release.
|
||||||
|
const CUSTOM_BINARIES = {
|
||||||
|
'darwin-arm64': 'https://github.com/Anil-matcha/Open-Generative-AI/releases/download/v1.0.3-binaries/sd-cli-metal-macos-arm64.zip',
|
||||||
|
};
|
||||||
|
|
||||||
async function downloadBinary(mainWindow) {
|
async function downloadBinary(mainWindow) {
|
||||||
const send = (data) => mainWindow?.webContents.send('local-ai:download-progress', { id: '__binary__', ...data });
|
const send = (data) => mainWindow?.webContents.send('local-ai:download-progress', { id: '__binary__', ...data });
|
||||||
|
|
||||||
try {
|
try {
|
||||||
send({ phase: 'fetching-release', progress: 0 });
|
send({ phase: 'fetching-release', progress: 0 });
|
||||||
|
|
||||||
|
const platformKey = `${process.platform}-${process.arch}`;
|
||||||
|
const customUrl = CUSTOM_BINARIES[platformKey];
|
||||||
|
|
||||||
|
let downloadUrl, zipName;
|
||||||
|
|
||||||
|
if (customUrl) {
|
||||||
|
downloadUrl = customUrl;
|
||||||
|
zipName = path.basename(customUrl);
|
||||||
|
} else {
|
||||||
const releaseData = await new Promise((resolve, reject) => {
|
const releaseData = await new Promise((resolve, reject) => {
|
||||||
https.get(
|
https.get(
|
||||||
'https://api.github.com/repos/leejet/stable-diffusion.cpp/releases/latest',
|
'https://api.github.com/repos/leejet/stable-diffusion.cpp/releases/latest',
|
||||||
|
|
@ -183,10 +199,13 @@ async function downloadBinary(mainWindow) {
|
||||||
const available = allZips.map(a => a.name).join(', ');
|
const available = allZips.map(a => a.name).join(', ');
|
||||||
throw new Error(`No binary found for this platform. Available: ${available}`);
|
throw new Error(`No binary found for this platform. Available: ${available}`);
|
||||||
}
|
}
|
||||||
|
downloadUrl = asset.browser_download_url;
|
||||||
|
zipName = asset.name;
|
||||||
|
}
|
||||||
|
|
||||||
send({ phase: 'downloading', progress: 0 });
|
send({ phase: 'downloading', progress: 0 });
|
||||||
const zipPath = path.join(BIN_DIR, asset.name);
|
const zipPath = path.join(BIN_DIR, zipName);
|
||||||
await downloadFile(asset.browser_download_url, zipPath, (p) => {
|
await downloadFile(downloadUrl, zipPath, (p) => {
|
||||||
send({ phase: 'downloading', progress: p });
|
send({ phase: 'downloading', progress: p });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue