Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.
JavaScript aianthropiccross-platformgeminigroqlinuxmacosnvidiaopen-sourceopenaiparakeetspeech-to-texttranscribewhisperwindows
fix(gpu): select multi-GPU device by UUID instead of numeric index (#1018)
Alcahest Malus Dienheimfd818bd1af0d
diff --git a/preload.js b/preload.jsindex 41f9aad4d..fa371475e 100644--- a/preload.js+++ b/preload.js@@ -217,7 +217,7 @@ contextBridge.exposeInMainWorld("electronAPI", {// CUDA GPU accelerationlistGpus: () => ipcRenderer.invoke("list-gpus"),- setGpuDeviceIndex: (purpose, index) => ipcRenderer.invoke("set-gpu-device-index", purpose, index),+ setGpuDeviceIndex: (purpose, uuid) => ipcRenderer.invoke("set-gpu-device-index", purpose, uuid),getGpuDeviceIndex: (purpose) => ipcRenderer.invoke("get-gpu-device-index", purpose),detectGpu: () => ipcRenderer.invoke("detect-gpu"),getCudaWhisperStatus: () => ipcRenderer.invoke("get-cuda-whisper-status"),diff --git a/src/components/SettingsPage.tsx b/src/components/SettingsPage.tsxindex c7dfc1e4d..7d99d0ac4 100644--- a/src/components/SettingsPage.tsx+++ b/src/components/SettingsPage.tsx@@ -609,17 +609,17 @@ function LlmsTabs({function GpuDeviceSelector({ purpose }: { purpose: "transcription" | "intelligence" }) {const { t } = useTranslation();const [gpus, setGpus] = useState<GpuDevice[]>([]);- const [selectedIndex, setSelectedIndex] = useState("0");+ const [selectedUuid, setSelectedUuid] = useState("");const [loaded, setLoaded] = useState(false);useEffect(() => {Promise.all([window.electronAPI?.listGpus?.() ?? Promise.resolve([]),- window.electronAPI?.getGpuDeviceIndex?.(purpose) ?? Promise.resolve("0"),+ window.electronAPI?.getGpuDeviceIndex?.(purpose) ?? Promise.resolve(""),])- .then(([gpuList, idx]) => {+ .then(([gpuList, savedUuid]) => {setGpus(gpuList);- setSelectedIndex(idx);+ setSelectedUuid(savedUuid || gpuList[0]?.uuid || "");setLoaded(true);}).catch(() => setLoaded(true));@@ -637,16 +637,16 @@ function GpuDeviceSelector({ purpose }: { purpose: "transcription" | "intelligen<SettingsPanelRow><div className="relative w-full"><select- value={selectedIndex}+ value={selectedUuid}onChange={async (e) => {- const idx = e.target.value;- setSelectedIndex(idx);- await window.electronAPI?.setGpuDeviceIndex?.(purpose, Number(idx));+ const uuid = e.target.value;+ setSelectedUuid(uuid);+ await window.electronAPI?.setGpuDeviceIndex?.(purpose, uuid);}}className="w-full appearance-none rounded-md border border-border bg-background px-3 pr-10 py-2 text-sm">{gpus.map((gpu) => (- <option key={gpu.index} value={String(gpu.index)}>+ <option key={gpu.uuid} value={gpu.uuid}>GPU {gpu.index}: {gpu.name} ({Math.round(gpu.vramMb / 1024)}GB)</option>))}diff --git a/src/helpers/environment.js b/src/helpers/environment.jsindex 6fee987c0..fb848787b 100644--- a/src/helpers/environment.js+++ b/src/helpers/environment.js@@ -50,8 +50,8 @@ const PERSISTED_KEYS = ["UI_LANGUAGE","WHISPER_CUDA_ENABLED","WHISPER_THREADS",- "TRANSCRIPTION_GPU_INDEX",- "INTELLIGENCE_GPU_INDEX",+ "TRANSCRIPTION_GPU_UUID",+ "INTELLIGENCE_GPU_UUID","BEDROCK_REGION","BEDROCK_PROFILE","AZURE_OPENAI_ENDPOINT",diff --git a/src/helpers/ipcHandlers.js b/src/helpers/ipcHandlers.jsindex a80a99f1a..b63729f20 100644--- a/src/helpers/ipcHandlers.js+++ b/src/helpers/ipcHandlers.js@@ -563,7 +563,10 @@ class IPCHandlers {if (gpus.length > 0) {debugLogger.info("NVIDIA GPUs detected",- { count: gpus.length, devices: gpus.map((g) => `${g.name} (${g.vramMb}MB)`) },+ {+ count: gpus.length,+ devices: gpus.map((g) => `[${g.index}] ${g.name} (${g.vramMb}MB) ${g.uuid}`),+ },"gpu");} else {@@ -1789,28 +1792,27 @@ class IPCHandlers {return listNvidiaGpus();});- ipcMain.handle("set-gpu-device-index", async (_event, purpose, index) => {+ ipcMain.handle("set-gpu-device-index", async (_event, purpose, uuid) => {if (purpose !== "transcription" && purpose !== "intelligence") {return { success: false };}- const parsed = parseInt(index, 10);- if (isNaN(parsed) || parsed < 0) {+ // Empty string clears the pinned GPU; otherwise require an nvidia-smi UUID. See #531.+ if (typeof uuid !== "string" || (uuid !== "" && !uuid.startsWith("GPU-"))) {return { success: false };}- const idx = String(parsed);- const key = purpose === "intelligence" ? "INTELLIGENCE_GPU_INDEX" : "TRANSCRIPTION_GPU_INDEX";- const oldIdx = process.env[key] || "0";- process.env[key] = idx;+ const key = purpose === "intelligence" ? "INTELLIGENCE_GPU_UUID" : "TRANSCRIPTION_GPU_UUID";+ const oldUuid = process.env[key] || "";+ process.env[key] = uuid;this.environmentManager.saveAllKeysToEnvFile().catch((err) => {- debugLogger.error("Failed to persist GPU index", { error: err.message }, "gpu");+ debugLogger.error("Failed to persist GPU UUID", { error: err.message }, "gpu");});- if (oldIdx !== idx) {+ if (oldUuid !== uuid) {try {if (purpose === "transcription" && this.whisperManager?.serverManager?.process) {debugLogger.info("Restarting whisper-server for GPU change",- { from: oldIdx, to: idx },+ { from: oldUuid, to: uuid },"gpu");const modelName = this.whisperManager.currentServerModel;@@ -1826,7 +1828,7 @@ class IPCHandlers {if (modelManager.serverManager?.process) {debugLogger.info("Restarting llama-server for GPU change",- { from: oldIdx, to: idx },+ { from: oldUuid, to: uuid },"gpu");const modelPath = modelManager.serverManager.modelPath;@@ -1850,10 +1852,10 @@ class IPCHandlers {ipcMain.handle("get-gpu-device-index", async (_event, purpose) => {if (purpose !== "transcription" && purpose !== "intelligence") {- return "0";+ return "";}- const key = purpose === "intelligence" ? "INTELLIGENCE_GPU_INDEX" : "TRANSCRIPTION_GPU_INDEX";- return process.env[key] || "0";+ const key = purpose === "intelligence" ? "INTELLIGENCE_GPU_UUID" : "TRANSCRIPTION_GPU_UUID";+ return process.env[key] || "";});ipcMain.handle("get-cuda-whisper-status", async () => {diff --git a/src/helpers/llamaServer.js b/src/helpers/llamaServer.jsindex 3aa1e4b14..892a43886 100644--- a/src/helpers/llamaServer.js+++ b/src/helpers/llamaServer.js@@ -208,8 +208,10 @@ class LlamaServerManager {env.PATH = binDir + (env.PATH ? `;${env.PATH}` : "");}- if (process.env.INTELLIGENCE_GPU_INDEX) {- env.CUDA_VISIBLE_DEVICES = process.env.INTELLIGENCE_GPU_INDEX;+ // Select GPU by UUID + PCI_BUS_ID order so the device is unambiguous. See #531.+ env.CUDA_DEVICE_ORDER = "PCI_BUS_ID";+ if (process.env.INTELLIGENCE_GPU_UUID) {+ env.CUDA_VISIBLE_DEVICES = process.env.INTELLIGENCE_GPU_UUID;}// Disable llama.cpp auto-fit memory probing (adds ~70s to startup). Set via envdiff --git a/src/helpers/whisperServer.js b/src/helpers/whisperServer.jsindex b7ec10b75..0e20fdd67 100644--- a/src/helpers/whisperServer.js+++ b/src/helpers/whisperServer.js@@ -427,8 +427,12 @@ class WhisperServerManager extends EventEmitter {const serverBinaryDir = path.dirname(serverBinary);spawnEnv.PATH = serverBinaryDir + pathSep + (process.env.PATH || "");- if (usingCuda && process.env.TRANSCRIPTION_GPU_INDEX) {- spawnEnv.CUDA_VISIBLE_DEVICES = process.env.TRANSCRIPTION_GPU_INDEX;+ // Select GPU by UUID + PCI_BUS_ID order so the device is unambiguous. See #531.+ if (usingCuda) {+ spawnEnv.CUDA_DEVICE_ORDER = "PCI_BUS_ID";+ if (process.env.TRANSCRIPTION_GPU_UUID) {+ spawnEnv.CUDA_VISIBLE_DEVICES = process.env.TRANSCRIPTION_GPU_UUID;+ }}const args = buildWhisperServerArgs({diff --git a/src/types/electron.ts b/src/types/electron.tsindex 8e9430089..a81d9abec 100644--- a/src/types/electron.ts+++ b/src/types/electron.ts@@ -218,6 +218,7 @@ export interface ActionItem {export interface GpuDevice {index: number;+ uuid: string;name: string;vramMb: number;}@@ -753,7 +754,7 @@ declare global {listGpus?: () => Promise<GpuDevice[]>;setGpuDeviceIndex?: (purpose: "transcription" | "intelligence",- index: number+ uuid: string) => Promise<{ success: boolean }>;getGpuDeviceIndex?: (purpose: "transcription" | "intelligence") => Promise<string>;detectGpu: () => Promise<GpuInfo>;diff --git a/src/utils/gpuDetection.js b/src/utils/gpuDetection.jsindex 83d81802a..f6caaae65 100644--- a/src/utils/gpuDetection.js+++ b/src/utils/gpuDetection.js@@ -57,7 +57,7 @@ function listNvidiaGpus() {return new Promise((resolve) => {execFile("nvidia-smi",- ["--query-gpu=index,name,memory.total", "--format=csv,noheader,nounits"],+ ["--query-gpu=index,uuid,name,memory.total", "--format=csv,noheader,nounits"],{ timeout: 5000 },(error, stdout) => {if (error || !stdout) {@@ -73,8 +73,9 @@ function listNvidiaGpus() {const parts = line.split(",").map((s) => s.trim());return {index: parseInt(parts[0], 10),- name: parts[1] || "Unknown GPU",- vramMb: parseInt(parts[2], 10) || 0,+ uuid: parts[1] || "",+ name: parts[2] || "Unknown GPU",+ vramMb: parseInt(parts[3], 10) || 0,};}).filter((g) => !isNaN(g.index));