Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

fix: CUDA and Vulkan binary download failures on Windows

Egorf92c274b3890
diff --git a/src/helpers/ipcHandlers.js b/src/helpers/ipcHandlers.js
index 193a141d2..07a7dc5a9 100644
--- a/src/helpers/ipcHandlers.js
+++ b/src/helpers/ipcHandlers.js
@@ -925,10 +925,11 @@ class IPCHandlers {
const { detectNvidiaGpu } = require("../utils/gpuDetection");
const gpuInfo = await detectNvidiaGpu();
if (!this.whisperCudaManager) {
- return { downloaded: false, path: null, gpuInfo };
+ return { downloaded: false, downloading: false, path: null, gpuInfo };
}
return {
downloaded: this.whisperCudaManager.isDownloaded(),
+ downloading: this.whisperCudaManager._downloading,
path: this.whisperCudaManager.getCudaBinaryPath(),
gpuInfo,
};
@@ -949,8 +950,11 @@ class IPCHandlers {
}
});
this._syncStartupEnv({ WHISPER_CUDA_ENABLED: "true" });
+ // Restart whisper-server so it picks up the CUDA binary
+ await this.whisperManager.stopServer().catch(() => {});
return { success: true };
} catch (error) {
+ debugLogger.error("CUDA binary download failed", { error: error.message, stack: error.stack });
return { success: false, error: error.message };
}
});
@@ -965,6 +969,8 @@ class IPCHandlers {
const result = await this.whisperCudaManager.delete();
if (result.success) {
this._syncStartupEnv({}, ["WHISPER_CUDA_ENABLED"]);
+ // Restart whisper-server so it falls back to CPU binary
+ await this.whisperManager.stopServer().catch(() => {});
}
return result;
});
@@ -1742,11 +1748,14 @@ class IPCHandlers {
delete process.env.LLAMA_GPU_BACKEND;
const modelManager = require("./modelManagerBridge").default;
modelManager.serverManager.cachedServerBinaryPaths = null;
+ // Restart llama server so it picks up the Vulkan binary
+ await modelManager.stopServer().catch(() => {});
this.environmentManager.saveAllKeysToEnvFile().catch(() => {});
}
return result;
} catch (error) {
+ debugLogger.error("Vulkan binary download failed", { error: error.message, stack: error.stack });
return { success: false, error: error.message };
}
});
diff --git a/src/helpers/llamaVulkanManager.js b/src/helpers/llamaVulkanManager.js
index 0e040ff76..20b81ef3f 100644
--- a/src/helpers/llamaVulkanManager.js
+++ b/src/helpers/llamaVulkanManager.js
@@ -213,17 +213,25 @@ class LlamaVulkanManager {
err ? reject(new Error(`Extraction failed: ${err.message}`)) : resolve();
});
} else if (process.platform === "win32") {
- execFile(
- "powershell",
- [
- "-NoProfile",
- "-Command",
- `Expand-Archive -Force -Path '${archivePath}' -DestinationPath '${destDir}'`,
- ],
- (err) => {
- err ? reject(new Error(`Extraction failed: ${err.message}`)) : resolve();
+ // Use Windows built-in tar.exe (available since Windows 10 1803)
+ execFile("tar", ["-xf", archivePath, "-C", destDir], (err) => {
+ if (err) {
+ debugLogger.info("Vulkan: tar extraction failed, trying PowerShell", { error: err.message });
+ execFile(
+ "powershell",
+ [
+ "-NoProfile",
+ "-Command",
+ `Expand-Archive -Force -Path '${archivePath}' -DestinationPath '${destDir}'`,
+ ],
+ (psErr) => {
+ psErr ? reject(new Error(`Extraction failed: ${psErr.message}`)) : resolve();
+ }
+ );
+ } else {
+ resolve();
}
- );
+ });
} else {
execFile("unzip", ["-o", archivePath, "-d", destDir], (err) => {
err ? reject(new Error(`Extraction failed: ${err.message}`)) : resolve();
diff --git a/src/helpers/whisperCudaManager.js b/src/helpers/whisperCudaManager.js
index bbf611f7a..1ad501b1c 100644
--- a/src/helpers/whisperCudaManager.js
+++ b/src/helpers/whisperCudaManager.js
@@ -38,6 +38,7 @@ class WhisperCudaManager {
constructor() {
this._binDir = null;
this._downloadSignal = null;
+ this._downloading = false;
}
getCudaBinaryDir() {
@@ -81,36 +82,42 @@ class WhisperCudaManager {
}
async download(progressCallback) {
+ if (this._downloading) throw new Error("Download already in progress");
if (!isSupportedPlatform()) {
throw new Error(`CUDA binaries not available for ${process.platform}`);
}
- const releaseInfo = await this.fetchReleaseInfo();
- debugLogger.info("CUDA binary download starting", {
- version: releaseInfo.version,
- size: releaseInfo.size,
- });
+ this._downloading = true;
- const binDir = this.getCudaBinaryDir();
+ let zipPath = null;
+ let extractDir = null;
- const spaceCheck = await checkDiskSpace(binDir, releaseInfo.size * 2);
- if (!spaceCheck.ok) {
- throw new Error(
- `Not enough disk space. Need ~${Math.round((releaseInfo.size * 2) / 1_000_000)}MB, ` +
- `only ${Math.round(spaceCheck.availableBytes / 1_000_000)}MB available.`
- );
- }
+ try {
+ const releaseInfo = await this.fetchReleaseInfo();
+ debugLogger.info("CUDA binary download starting", {
+ version: releaseInfo.version,
+ size: releaseInfo.size,
+ });
- await cleanupStaleDownloads(binDir);
+ const binDir = this.getCudaBinaryDir();
- const { signal, abort } = createDownloadSignal();
- this._downloadSignal = { abort };
+ const spaceCheck = await checkDiskSpace(binDir, releaseInfo.size * 2);
+ if (!spaceCheck.ok) {
+ throw new Error(
+ `Not enough disk space. Need ~${Math.round((releaseInfo.size * 2) / 1_000_000)}MB, ` +
+ `only ${Math.round(spaceCheck.availableBytes / 1_000_000)}MB available.`
+ );
+ }
- const tempDir = getSafeTempDir();
- const zipPath = path.join(tempDir, `cuda-download-${Date.now()}.zip`);
- const extractDir = path.join(tempDir, `temp-extract-${Date.now()}`);
+ await cleanupStaleDownloads(binDir);
+
+ const { signal, abort } = createDownloadSignal();
+ this._downloadSignal = { abort };
+
+ const tempDir = getSafeTempDir();
+ zipPath = path.join(tempDir, `cuda-download-${Date.now()}.zip`);
+ extractDir = path.join(tempDir, `temp-extract-${Date.now()}`);
- try {
await downloadFile(releaseInfo.url, zipPath, {
timeout: 600000,
signal,
@@ -132,22 +139,25 @@ class WhisperCudaManager {
const binaryName = PLATFORM_BINARY_NAMES[process.platform];
const companionPattern = COMPANION_PATTERNS[process.platform];
- const entries = await fsPromises.readdir(extractDir);
- for (const entry of entries) {
- if (entry === binaryName || companionPattern.test(entry)) {
- const src = path.join(extractDir, entry);
- const dest = path.join(binDir, entry);
- await fsPromises.copyFile(src, dest);
+ const binaryPath = this._findFile(extractDir, binaryName);
+ if (!binaryPath) {
+ throw new Error(`Extraction completed but binary "${binaryName}" not found in archive`);
+ }
- if (process.platform === "linux") {
- await fsPromises.chmod(dest, 0o755);
- }
- }
+ const dest = path.join(binDir, binaryName);
+ await fsPromises.copyFile(binaryPath, dest);
+ if (process.platform === "linux") {
+ await fsPromises.chmod(dest, 0o755);
}
- if (!this.getCudaBinaryPath()) {
- throw new Error(`Extraction completed but binary "${binaryName}" not found in archive`);
+ const libs = this._findFiles(extractDir, companionPattern);
+ for (const lib of libs) {
+ const libDest = path.join(binDir, path.basename(lib));
+ await fsPromises.copyFile(lib, libDest);
+ if (process.platform === "linux") {
+ await fsPromises.chmod(libDest, 0o755);
+ }
}
debugLogger.info("CUDA binary download complete", {
@@ -164,9 +174,10 @@ class WhisperCudaManager {
}
throw error;
} finally {
+ this._downloading = false;
this._downloadSignal = null;
- await fsPromises.unlink(zipPath).catch(() => {});
- await fsPromises.rm(extractDir, { recursive: true, force: true }).catch(() => {});
+ if (zipPath) await fsPromises.unlink(zipPath).catch(() => {});
+ if (extractDir) await fsPromises.rm(extractDir, { recursive: true, force: true }).catch(() => {});
}
}
@@ -221,6 +232,36 @@ class WhisperCudaManager {
};
}
+ _findFile(dir, name, maxDepth = 5, depth = 0) {
+ if (depth >= maxDepth) return null;
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
+ for (const entry of entries) {
+ const full = path.join(dir, entry.name);
+ if (entry.isDirectory()) {
+ const found = this._findFile(full, name, maxDepth, depth + 1);
+ if (found) return found;
+ } else if (entry.name === name) {
+ return full;
+ }
+ }
+ return null;
+ }
+
+ _findFiles(dir, pattern, maxDepth = 5, depth = 0) {
+ if (depth >= maxDepth) return [];
+ const results = [];
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
+ for (const entry of entries) {
+ const full = path.join(dir, entry.name);
+ if (entry.isDirectory()) {
+ results.push(...this._findFiles(full, pattern, maxDepth, depth + 1));
+ } else if (pattern.test(entry.name)) {
+ results.push(full);
+ }
+ }
+ return results;
+ }
+
_fetchJson(url) {
return new Promise((resolve, reject) => {
https
@@ -274,18 +315,27 @@ class WhisperCudaManager {
_extractZip(zipPath, destDir) {
if (process.platform === "win32") {
return new Promise((resolve, reject) => {
- execFile(
- "powershell",
- [
- "-NoProfile",
- "-Command",
- `Expand-Archive -Force -Path '${zipPath}' -DestinationPath '${destDir}'`,
- ],
- (error) => {
- if (error) reject(new Error(`Zip extraction failed: ${error.message}`));
- else resolve();
+ // Use Windows built-in tar.exe (available since Windows 10 1803)
+ execFile("tar", ["-xf", zipPath, "-C", destDir], (error) => {
+ if (error) {
+ debugLogger.info("CUDA: tar extraction failed, trying PowerShell", { error: error.message });
+ // Fallback to PowerShell Expand-Archive
+ execFile(
+ "powershell",
+ [
+ "-NoProfile",
+ "-Command",
+ `Expand-Archive -Force -Path '${zipPath}' -DestinationPath '${destDir}'`,
+ ],
+ (psError) => {
+ if (psError) reject(new Error(`Zip extraction failed: ${psError.message}`));
+ else resolve();
+ }
+ );
+ } else {
+ resolve();
}
- );
+ });
});
}