Project NOMAD is an offline-first knowledge and education server. Wikipedia, thousands of books, courses, maps, and optional local AI, all running on hardware you own with no internet required.
TypeScript
fix(GPU): persist GPU type to KV store for reliable passthrough
Chris Sherwood571f6bb5a275
diff --git a/admin/app/services/docker_service.ts b/admin/app/services/docker_service.tsindex 06df75cb..5d94f545 100644--- a/admin/app/services/docker_service.ts+++ b/admin/app/services/docker_service.ts@@ -691,6 +691,7 @@ export class DockerService {const runtimes = dockerInfo.Runtimes || {}if ('nvidia' in runtimes) {logger.info('[DockerService] NVIDIA container runtime detected via Docker API')+ await this._persistGPUType('nvidia')return { type: 'nvidia' }}} catch (error) {@@ -722,12 +723,26 @@ export class DockerService {)if (amdCheck.trim()) {logger.info('[DockerService] AMD GPU detected via lspci')+ await this._persistGPUType('amd')return { type: 'amd' }}} catch (error) {// lspci not available, continue}+ // Last resort: check if we previously detected a GPU and it's likely still present.+ // This handles cases where live detection fails transiently (e.g., Docker daemon+ // hiccup, runtime temporarily unavailable) but the hardware hasn't changed.+ try {+ const savedType = await KVStore.getValue('gpu.type')+ if (savedType === 'nvidia' || savedType === 'amd') {+ logger.info(`[DockerService] No GPU detected live, but KV store has '${savedType}' from previous detection. Using saved value.`)+ return { type: savedType as 'nvidia' | 'amd' }+ }+ } catch {+ // KV store not available, continue+ }+logger.info('[DockerService] No GPU detected')return { type: 'none' }} catch (error) {@@ -736,6 +751,15 @@ export class DockerService {}}+ private async _persistGPUType(type: 'nvidia' | 'amd'): Promise<void> {+ try {+ await KVStore.setValue('gpu.type', type)+ logger.info(`[DockerService] Persisted GPU type '${type}' to KV store`)+ } catch (error) {+ logger.warn(`[DockerService] Failed to persist GPU type: ${error.message}`)+ }+ }+/*** Discover AMD GPU DRI devices dynamically.* Returns an array of device configurations for Docker.diff --git a/admin/types/kv_store.ts b/admin/types/kv_store.tsindex d752f006..814ebd4c 100644--- a/admin/types/kv_store.ts+++ b/admin/types/kv_store.ts@@ -9,6 +9,7 @@ export const KV_STORE_SCHEMA = {'ui.hasVisitedEasySetup': 'boolean','ui.theme': 'string','ai.assistantCustomName': 'string',+ 'gpu.type': 'string',} as consttype KVTagToType<T extends string> = T extends 'boolean' ? boolean : string