{"record":{"id":"7d87f476e128fc30","repo":"janhq/jan","slug":"failed-to-load-llamacpp-backend","errorCode":null,"errorMessage":"Failed to load llamacpp backend","messagePattern":"Failed to load llamacpp backend","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"extensions/llamacpp-extension/src/index.ts","lineNumber":2831,"sourceCode":"                        return { ...dev, mem: total, free }\n                      }\n                    }\n                  }\n                }\n                return dev\n              })\n              return adjusted\n            }\n          }\n        }\n      } catch (e) {\n        logger.warn('Device memory override (AMD/Linux) failed:', e)\n      }\n\n      return dList\n    } catch (error) {\n      logger.error('Failed to query devices:\\n', error)\n      throw new Error('Failed to load llamacpp backend')\n    }\n  }\n\n  /**\n   * Resolves the default/preferred embedding model, importing and loading\n   * sentence-transformer-mini as the fallback, then ensures a session exists.\n   * Shared by embed() and getEmbeddingContextSize() so both agree on which\n   * model is \"the\" embedding model.\n   */\n  private async ensureEmbeddingModelLoaded(): Promise<SessionInfo> {\n    const downloadedModelList = await this.list()\n    const installedEmbedding = downloadedModelList.filter(\n      (m) => (m as any).embedding === true\n    )\n    const hasMini = downloadedModelList.some(\n      (m) => m.id === FALLBACK_EMBEDDING_MODEL_ID\n    )\n    let preferred = await getDefaultEmbeddingModelId('llamacpp')","sourceCodeStart":2813,"sourceCodeEnd":2849,"githubUrl":"https://github.com/janhq/jan/blob/7205d770c1e097c3daf35a911176410e93bc5564/extensions/llamacpp-extension/src/index.ts#L2813-L2849","documentation":"Thrown by the llamacpp extension's device-listing routine when querying available GPU/compute devices via the underlying backend fails for any reason. The original error is logged, then replaced with this generic message, so the root cause (driver, backend library, IPC failure) is only visible in logs. It indicates the llamacpp backend could not be initialized enough to enumerate devices.","triggerScenarios":"Calling the device-list API (e.g. listDevices/providers) when the native llama.cpp backend fails to load or its device query throws — missing/Corrupt Vulkan/CUDA/Metal drivers, incompatible backend binaries, or a crashed native process.","commonSituations":"Users on machines without required GPU drivers, after upgrading llama.cpp backend binaries, on WSL/VMs without GPU passthrough, or when the backend shared library fails to dlopen.","solutions":["Check extension logs for the 'Failed to query devices' entry to find the root cause error","Update or reinstall GPU drivers (Vulkan/CUDA/Metal) appropriate for your hardware","Reinstall or update the llamacpp extension so backend binaries match your platform","Fall back to CPU-only configuration by removing GPU device overrides","Report the logged root cause to the extension maintainers if drivers are healthy"],"exampleFix":"// before\nconst devices = await getDevices()\n// after\nlet devices = []\ntry {\n  devices = await getDevices()\n} catch (e) {\n  logger.warn('GPU device query failed, falling back to CPU', e)\n}","handlingStrategy":"fallback","validationCode":"// Precheck GPU availability before querying devices\nconst hasGpu = navigator.gpu !== undefined // or platform driver check\nif (!hasGpu) console.warn('No GPU detected; backend device query may fail')","typeGuard":null,"tryCatchPattern":"try {\n  const devices = await getDevices()\n} catch (e) {\n  logger.warn('Device query failed, continuing without GPU devices', e)\n}","preventionTips":["Keep GPU drivers (Vulkan/CUDA/Metal) up to date","Reinstall the extension after app upgrades so backend binaries match","Check logs for the underlying 'Failed to query devices' root cause","Test backend availability at app startup, not mid-session"],"tags":["backend","gpu","native","llamacpp"],"backgroundTag":"module-init-failed","analyzedSha":"7205d770c1e097c3daf35a911176410e93bc5564","analyzedAt":"2026-09-17T14:27:30.100Z","contentChangedAt":"2026-09-17T14:27:30.100Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}