invoke-ai/InvokeAI · error · Exception
Model not found: {model_path}
Error message
Model not found: {model_path} What it means
OnnxRuntimeModel.from_pretrained() accepts a model_id that is either a Hub repo id (downloaded first) or a local path. If the resolved model_path is not an existing file (os.path.isfile fails), it raises this Exception — the ONNX model file itself is missing.
Source
Thrown at invokeai/backend/onnx/onnx_runtime.py:220
file_name: Optional[str] = None,
provider: Optional[str] = None,
sess_options: Optional["SessionOptions"] = None,
**kwargs: Any,
) -> Any: # fixme
file_name = file_name or ONNX_WEIGHTS_NAME
if os.path.isdir(model_id):
model_path = model_id
if subfolder is not None:
model_path = os.path.join(model_path, subfolder)
model_path = os.path.join(model_path, file_name)
else:
model_path = model_id
# load model from local directory
if not os.path.isfile(model_path):
raise Exception(f"Model not found: {model_path}")
# TODO: session options
return cls(str(model_path), provider=provider)
View on GitHub (pinned to 0b6a024f2f)
Solutions
- Point model_id at the actual .onnx file (e.g. /path/to/model/model.onnx), not the containing directory.
- Verify the file exists: ls the directory and confirm the ONNX artifact downloaded completely.
- If using a Hub id, ensure network access/cache (HF_HOME) so the download succeeds before load.
- Re-export or re-download the ONNX model if the artifact is missing.
Example fix
// before
pipe = OnnxStableDiffusionPipeline.from_pretrained('/models/sdxl-onnx/')
// after (point at the onnx file expected by the loader, or the repo root containing it)
pipe = OnnxStableDiffusionPipeline.from_pretrained('/models/sdxl-onnx', variant='fp16') Defensive patterns
Strategy: validation
Validate before calling
import os
model_path = resolve(model_id)
if not os.path.isfile(model_path):
raise FileNotFoundError(f'Provide the path to the .onnx file; {model_path} is missing') Type guard
from pathlib import Path
def onnx_file_ready(p) -> bool:
path = Path(p)
return path.is_file() and path.suffix.lower() == '.onnx' Try / catch
try:
model = OnnxRuntimeModel.from_pretrained(model_id, provider=provider)
except Exception as e:
if str(e).startswith('Model not found:'):
missing = str(e).split(': ', 1)[1]
print(f'{missing} does not exist — check the path or re-download the ONNX model')
else:
raise Prevention
- Confirm the .onnx artifact exists on disk before from_pretrained.
- Check download completeness (file size, no partial dirs) after fetching ONNX repos.
- Use stable local model directories; avoid moving/renaming mid-pipeline.
When it happens
Trigger: Passing a directory that contains no ONNX model file, a path to a non-existent location, or a repo id whose download did not produce the expected .onnx file, so `not os.path.isfile(model_path)` triggers.
Common situations: Pointing model_id at the model folder instead of the .onnx file inside it; incomplete/cancelled downloads leaving empty dirs; renamed or moved model directories; expecting from_pretrained to fetch from the Hub while offline with no cached copy.
Related errors
- ImageFileNotFoundException
- Backslashes not allowed in subfolder path
- Absolute paths not allowed in subfolder path
- Empty path segments not allowed in subfolder path
- Source image does not exist: {move.old_path}
AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29).
Data as JSON: /api/errors/a2a623b515118c3d.
Report an issue: GitHub.