abhigyanpatwari/GitNexus · error · Error
No suitable device found
Error message
No suitable device found
What it means
Terminal failure of initEmbedder's device-probing loop: every candidate device failed for reasons that did not short-circuit earlier (download failures and the cpu-specific message throw their own errors), so no inference device could run the embedding model. The embedder instance and init promise are reset, so a later call retries the whole probe.
Source
Thrown at gitnexus/src/mcp/core/embedder.ts:160
// Network errors and circuit-open errors are not device-specific —
// they will fail the same way on every device. Rethrow immediately
// with actionable HF_ENDPOINT guidance rather than silently falling
// back to the next device.
const errMsg = deviceError instanceof Error ? deviceError.message : String(deviceError);
if (isHfDownloadFailure(errMsg)) {
const endpointHint = process.env.HF_ENDPOINT
? `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 (device === 'cpu') throw new Error('Failed to load embedding model');
}
}
throw new Error('No suitable device found');
} catch (error) {
isInitializing = false;
initPromise = null;
embedderInstance = null;
throw error;
} finally {
isInitializing = false;
}
})();
return initPromise;
};
/**
* Check if embedder is ready
*/
export const isEmbedderReady = (): boolean => isHttpMode() || embedderInstance !== null;
View on GitHub (pinned to aac7515d2a)
Solutions
- Check for resource exhaustion first: free memory, watch dmesg/task manager for OOM kills, and retry on a less constrained host or container.
- Pin a device explicitly with GITNEXUS_EMBEDDING_DEVICE=cpu to skip broken accelerated paths.
- Reinstall the embedding stack via `gitnexus embeddings install` to repair a broken onnxruntime/transformers pairing.
- Switch to HTTP embeddings with GITNEXUS_EMBEDDING_URL + GITNEXUS_EMBEDDING_MODEL so no local device is needed.
- If all routes fail, capture the per-device errors from the logs and file a GitNexus issue.
Example fix
# before: every device candidate fails $ gitnexus analyze --embeddings # → No suitable device found # after: pin cpu, repair stack, or move to HTTP embeddings $ GITNEXUS_EMBEDDING_DEVICE=cpu gitnexus embeddings install $ GITNEXUS_EMBEDDING_DEVICE=cpu gitnexus analyze --embeddings # or: export GITNEXUS_EMBEDDING_URL=... GITNEXUS_EMBEDDING_MODEL=... and retry
Defensive patterns
Strategy: fallback
Validate before calling
// Pre-flight: memory headroom and pinned device before embedding runs
import os from 'node:os';
function embeddingPreconditionsOk(): boolean {
const freeMb = os.freemem() / 1024 / 1024;
return freeMb > 1024; // model load needs real headroom, not the bare minimum
}
process.env.GITNEXUS_EMBEDDING_DEVICE ??= 'cpu'; // skip broken accelerated paths by default Try / catch
try {
await initEmbedder();
} catch (err) {
if (err instanceof Error && err.message === 'No suitable device found') {
// all devices failed: degrade gracefully, index without semantic search
logger.warn('embeddings unavailable — continuing without them');
return runAnalyze({ embeddings: false });
}
throw err;
} Prevention
- Reserve adequate memory (container limits, no parallel heavy jobs) during embedding runs.
- Set GITNEXUS_EMBEDDING_DEVICE=cpu explicitly on hosts with flaky GPU runtimes.
- Keep the embedding stack repaired via `gitnexus embeddings install` after runtime upgrades.
- Design pipelines so embeddings are an optional enhancement, never a hard dependency.
When it happens
Trigger: GPU device candidates fail (driver/runtime mismatch, no WebGL/WASM support in the Node build) AND the cpu attempt fails for a non-network reason such as memory exhaustion or a broken native runtime — the loop exhausts all devices without a classifiable error.
Common situations: Containers with strict memory limits where model load OOMs on every device; minimal Node runtimes missing WASM support; hosts with mismatched GPU drivers where both accelerated and fallback paths are broken; rarely, deeply corrupted installs.
Related errors
- embedding device must be one of auto, dml, cuda, cpu, wasm;
- Local semantic embeddings are unavailable on macOS Intel (da
- Local semantic embeddings are unavailable: the optional embe
- No suitable device found for embedding model
- Local semantic embeddings are unavailable on macOS Intel (da
AI-assisted analysis of abhigyanpatwari/GitNexus@aac7515d2a (2026-08-20).
Data as JSON: /api/errors/5acabbf301d42ee1.
Report an issue: GitHub.