{"record":{"id":"eaba5267a7c8a7fc","repo":"abhigyanpatwari/GitNexus","slug":"no-suitable-device-found-for-embedding-model-local-init","errorCode":null,"errorMessage":"No suitable device found for embedding model","messagePattern":"No suitable device found for embedding model","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gitnexus/src/core/embeddings/embedding-local-init.ts","lineNumber":185,"sourceCode":"            const endpointHint = process.env.HF_ENDPOINT\n              ? `The configured endpoint (${process.env.HF_ENDPOINT}) may be unreachable.`\n              : `huggingface.co may be unreachable from your network.\\n` +\n                `  Set HF_ENDPOINT to a mirror and retry:\\n` +\n                `    HF_ENDPOINT=https://hf-mirror.com npx gitnexus analyze --embeddings\\n` +\n                `    (Windows: set HF_ENDPOINT=https://hf-mirror.com && npx gitnexus analyze --embeddings)`;\n            throw new Error(`Failed to download embedding model: ${errMsg}\\n  ${endpointHint}`);\n          }\n          if (isDev && (device === 'cuda' || device === 'dml')) {\n            const gpuType = device === 'dml' ? 'DirectML' : 'CUDA';\n            logger.info(`⚠️  ${gpuType} not available, falling back to CPU...`);\n          }\n          if (device === devicesToTry[devicesToTry.length - 1]) {\n            throw deviceError;\n          }\n        }\n      }\n\n      throw new Error('No suitable device found for embedding model');\n    } catch (error) {\n      initPromise = null;\n      embedderInstance = null;\n      throw error;\n    }\n  })();\n\n  return initPromise;\n};\n\nconst getLocalEmbedder = (): FeatureExtractionPipeline => {\n  if (!embedderInstance) {\n    throw new Error('Embedder not initialized. Call initLocalEmbedder() first.');\n  }\n  return embedderInstance;\n};\n\nexport const localEmbedBatch = async (texts: string[]): Promise<Float32Array[]> => {","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/ac9a4e9abd8fd3058c070b72c23402a4f887929a/gitnexus/src/core/embeddings/embedding-local-init.ts#L167-L203","documentation":"initLocalEmbedder throws this after exhausting every candidate device (e.g. webgpu/cuda/dml then cpu): each attempt failed with its own deviceError, and the last attempt's error was re-thrown before reaching this line only if it was not the final device. Reaching this throw means the devicesToTry loop somehow ended without a successful pipeline and without the last device re-throwing — an exhaustion fallback indicating no execution provider could run the embedding model.","triggerScenarios":"Calling initLocalEmbedder() when pipeline creation fails on every device in devicesToTry — e.g. broken/corrupted onnxruntime-node install, GPU drivers missing while forced device was expected to fall back, or an ONNX build incompatible with the CPU.","commonSituations":"Damaged embedding-runtime prefix (interrupted install); containers without GPU drivers where non-CPU devices fail and CPU also fails due to a bad onnxruntime build; very old CPUs lacking required instruction sets.","solutions":["Reinstall the runtime: `gitnexus embeddings install --force` (or a clean reinstall) to repair a corrupted onnxruntime.","Run `gitnexus doctor` to check the embedding runtime and device status.","Try explicitly setting GITNEXUS_EMBEDDING_DEVICE=cpu to skip GPU attempts and see the underlying CPU error.","If the CPU lacks required instructions or onnxruntime cannot load at all, switch to GITNEXUS_EMBEDDING_URL HTTP embedding.","Inspect the deviceError logged during the loop for the root cause of each failed device."],"exampleFix":"// before: every device fails, root cause hidden\nconst embedder = await initLocalEmbedder();\n// after (shell): isolate the CPU failure and repair the runtime\nGITNEXUS_EMBEDDING_DEVICE=cpu node -e \"...initLocalEmbedder()\"  # see real deviceError\ngitnexus embeddings install --force","handlingStrategy":"try-catch","validationCode":"import { assessLocalEmbeddingRuntime } from 'gitnexus/src/core/embeddings/runtime-support.js';\nif (assessLocalEmbeddingRuntime().status !== 'ready') {\n  throw new Error('Embedding runtime not ready; run gitnexus doctor / embeddings install');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await initLocalEmbedder();\n} catch (err) {\n  if (err.message === 'No suitable device found for embedding model') {\n    // reinstall runtime with --force, retry with GITNEXUS_EMBEDDING_DEVICE=cpu, or use HTTP embedding\n  }\n}","preventionTips":["Run `gitnexus doctor` to verify device/runtime health before embedding jobs","Repair interrupted installs with `gitnexus embeddings install --force`","Force GITNEXUS_EMBEDDING_DEVICE=cpu in containers lacking GPU drivers","Fall back to HTTP embedding when no execution provider is viable"],"tags":["embedding","device","onnx","gpu","initialization"],"backgroundTag":"module-init-failed","analyzedSha":"ac9a4e9abd8fd3058c070b72c23402a4f887929a","analyzedAt":"2026-09-15T23:29:44.066Z","contentChangedAt":"2026-09-15T23:29:44.066Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}