diff --git a/web/hooks/useSettings.ts b/web/hooks/useSettings.ts index 874381317..0f02d41af 100644 --- a/web/hooks/useSettings.ts +++ b/web/hooks/useSettings.ts @@ -53,7 +53,7 @@ export const useSettings = () => { const settings = await readSettings() if (runMode != null) settings.run_mode = runMode if (notify != null) settings.notify = notify - if (gpusInUse != null) settings.gpus_in_use = gpusInUse + if (gpusInUse != null) settings.gpus_in_use = gpusInUse.filter((e) => !!e) if (vulkan != null) { settings.vulkan = vulkan // GPU enabled, set run_mode to 'gpu' diff --git a/web/screens/Settings/Advanced/index.tsx b/web/screens/Settings/Advanced/index.tsx index 62a2aded0..114bb2460 100644 --- a/web/screens/Settings/Advanced/index.tsx +++ b/web/screens/Settings/Advanced/index.tsx @@ -207,7 +207,12 @@ const Advanced = () => { let updatedGpusInUse = [...gpusInUse] if (updatedGpusInUse.includes(gpuId)) { updatedGpusInUse = updatedGpusInUse.filter((id) => id !== gpuId) - if (gpuEnabled && updatedGpusInUse.length === 0) { + if ( + gpuEnabled && + updatedGpusInUse.length === 0 && + gpuId && + gpuId.trim() + ) { // Vulkan support only allow 1 active device at a time if (vulkanEnabled) { updatedGpusInUse = [] @@ -219,10 +224,10 @@ const Advanced = () => { if (vulkanEnabled) { updatedGpusInUse = [] } - updatedGpusInUse.push(gpuId) + if (gpuId && gpuId.trim()) updatedGpusInUse.push(gpuId) } setGpusInUse(updatedGpusInUse) - await saveSettings({ gpusInUse: updatedGpusInUse }) + await saveSettings({ gpusInUse: updatedGpusInUse.filter((e) => !!e) }) // Reload window to apply changes // This will trigger engine servers to restart window.location.reload()