abhigyanpatwari/GitNexus · error
No suitable device found for embedding model
Error message
No suitable device found for embedding model
What it means
Thrown by getEmbedder() when the @huggingface/transformers pipeline() call fails to create an ONNX Runtime session on every candidate device. Devices tried are [requestedDevice, 'cpu'] for GITNEXUS_EMBEDDING_DEVICE=cuda|dml, or just ['cpu']/['wasm'] otherwise; note that when the LAST device fails, the original deviceError propagates (embedder.ts:247), so this literal message is the defensive exhaustiveness guard for the no-device-succeeded path.
Solutions
- Set GITNEXUS_EMBEDDING_DEVICE=cpu explicitly and retry to bypass GPU probing.
- Clear the HuggingFace cache (rm -rf ~/.cache/huggingface or your HF_HOME dir) so the model re-downloads cleanly.
- Free memory or reduce GITNEXUS_EMBEDDING_THREADS; fp32 sessions are large.
- Reinstall gitnexus so onnxruntime-node native bindings match your Node version.
- Switch to HTTP embedding mode (set GITNEXUS_EMBEDDING_URL + GITNEXUS_EMBEDDING_MODEL) to skip local ONNX entirely.
Example fix
# before GITNEXUS_EMBEDDING_DEVICE=cuda npx gitnexus analyze --embeddings # after (force CPU, or use an HTTP endpoint) GITNEXUS_EMBEDDING_DEVICE=cpu npx gitnexus analyze --embeddings # or: export GITNEXUS_EMBEDDING_URL=http://localhost:11434/v1 GITNEXUS_EMBEDDING_MODEL=nomic-embed-text
Defensive patterns
Strategy: fallback
Validate before calling
import { isEmbedderReady, getEmbedder } from './embedder';
// warm the model at startup, not lazily mid-query
if (!isEmbedderReady()) {
await getEmbedder(); // throws early with the real deviceError
} Type guard
const isDeviceError = (e: unknown): boolean => e instanceof Error && /No suitable device found|device/i.test(e.message);
Try / catch
try {
await getEmbedder();
} catch (e) {
if (e instanceof Error && e.message.includes('No suitable device')) {
// fall back to HTTP embedding mode or skip embeddings
} else throw e;
} Prevention
- Set GITNEXUS_EMBEDDING_DEVICE=cpu in CI/containers where GPU runtimes are absent or broken.
- Warm up the embedder at process start so device failures surface before long indexing work.
- Keep HF_HOME on writable storage and clear it after upgrading gitnexus/model versions.
- Provide an HTTP embedding endpoint as the deployment-grade fallback.
When it happens
Trigger: Initializing the local embedding model with GITNEXUS_EMBEDDING_DEVICE=cuda or dml where GPU init fails AND the CPU fallback also fails (or a direct cpu/wasm request failing), e.g. onnxruntime native module mismatch, corrupted model cache under ~/.cache/huggingface, or insufficient memory for even the CPU session.
Common situations: Node/onnxruntime-node version skew after a package upgrade, a partially downloaded model in the HF cache, CI containers without GPU libs where even CPU WASM init fails, or low-memory environments where the fp32 session cannot allocate.
Related errors
- No suitable device found for embedding model
- Embedding model not initialized. Run embedding pipeline…
- Failed to load embedding model
- Local semantic embeddings are unavailable on macOS Intel…
- Local semantic embeddings are unavailable on macOS Intel…
AI-assisted analysis of abhigyanpatwari/GitNexus@aac7515d2a (2026-08-20).
Data as JSON: /api/errors/a0be2c45f3191287.
Report an issue: GitHub.
Appendix: source
Thrown at gitnexus/src/core/embeddings/embedder.ts:252
? `The configured endpoint (${process.env.HF_ENDPOINT}) may be unreachable.`
: `huggingface.co may be unreachable from your network.\n` +
` Set HF_ENDPOINT to a mirror and retry:\n` +
` HF_ENDPOINT=https://hf-mirror.com npx gitnexus analyze --embeddings\n` +
` (Windows: set HF_ENDPOINT=https://hf-mirror.com && npx gitnexus analyze --embeddings)`;
throw new Error(`Failed to download embedding model: ${errMsg}\n ${endpointHint}`);
}
if (isDev && (device === 'cuda' || device === 'dml')) {
const gpuType = device === 'dml' ? 'DirectML' : 'CUDA';
logger.info(`⚠️ ${gpuType} not available, falling back to CPU...`);
}
// Continue to next device in list
if (device === devicesToTry[devicesToTry.length - 1]) {
throw deviceError; // Last device failed, propagate error
}
}
}
throw new Error('No suitable device found for embedding model');
} catch (error) {
isInitializing = false;
initPromise = null;
embedderInstance = null;
throw error;
} finally {
isInitializing = false;
}
})();
return initPromise;
};
/**
* Check if the embedder is initialized and ready
*/
export const isEmbedderReady = (): boolean => {
return isHttpMode() || embedderInstance !== null;View on GitHub (pinned to aac7515d2a)