odysseus-dev/odysseus · error · RuntimeError
Could not load model from {model_path}. Check diffusers vers
Error message
Could not load model from {model_path}. Check diffusers version and model format. What it means
RuntimeError from scripts/diffusion_server.py: every loader strategy for the requested model failed — the pipeline loop over diffusers classes (from_pretrained / from_single_file with config variants) raised, leaving loaded=False, so the server aborts with 'Could not load model from {model_path}. Check diffusers version and model format.' Preceding WARN lines ('<Cls>.from_single_file (config=...) failed: ...') carry the real per-strategy causes.
Source
Thrown at scripts/diffusion_server.py:638
kwargs["config"] = local_config
logger.info(f"Trying {cls_name}.from_single_file with config={config}")
_pipe = cls.from_single_file(single_file, **kwargs)
_fix_meta_tensors(_pipe, torch_dtype)
if use_offload and _can_cpu_offload(target_device):
_pipe.enable_model_cpu_offload()
logger.info(f"Loaded as {cls_name} (single file, config={config}) with CPU offload")
else:
_pipe = _pipe.to(target_device)
logger.info(f"Loaded as {cls_name} (single file, config={config}) on {target_device}")
loaded = True
break
except Exception as e:
logger.warning(f"{cls_name}.from_single_file (config={config}) failed: {e}")
_pipe = None
_cleanup()
if not loaded:
raise RuntimeError(f"Could not load model from {model_path}. Check diffusers version and model format.")
# Memory optimizations
if _args.attention_slicing:
try:
_pipe.enable_attention_slicing()
logger.info("Attention slicing enabled")
except Exception:
pass
if _args.vae_slicing:
try:
_pipe.enable_vae_slicing()
logger.info("VAE slicing enabled")
except Exception:
pass
logger.info(f"Model loaded: {_model_id}")
# Load LoRA weights if specifiedView on GitHub (pinned to f9235ebbf1)
Solutions
- Read the WARNING lines just above the traceback — they name each class/config attempt and its exception; fix that root cause first
- Upgrade/align the diffusers version to one supporting the model's pipeline class (check the model card's required version)
- For single-file checkpoints, pass an explicit config (e.g. config='./configs/sdxl' style argument the script supports) or convert to a diffusers repo layout
- Verify the download: re-run with a clean cache / check file sizes against the source repo
- Confirm the path is a directory containing model_index.json when using repo-format models
Example fix
# before pip install diffusers==0.24.0 python scripts/diffusion_server.py --model ./flux1-dev.safetensors # RuntimeError: Could not load model ... # after: use a diffusers release that supports the architecture pip install -U diffusers transformers accelerate safetensors python scripts/diffusion_server.py --model ./flux1-dev.safetensors
Defensive patterns
Strategy: fallback
Validate before calling
import importlib.metadata as md
from packaging.version import Version
required = {"FLuxPipeline": "0.30.0", "StableDiffusionXLPipeline": "0.24.0"} # per model card
assert Version(md.version("diffusers")) >= Version(required[cls]), "upgrade diffusers"
assert Path(model_path).exists() and (Path(model_path)/'model_index.json').exists() or model_path.endswith(('.safetensors','.ckpt')) Type guard
def is_supported_checkpoint(path: str) -> bool:
p = Path(path)
return (p.is_dir() and (p / 'model_index.json').exists()) or p.suffix in {'.safetensors', '.ckpt'} Try / catch
try:
serve_model(model_path)
except RuntimeError as e:
if 'Could not load model' in str(e):
# read the preceding '<Cls>.from_single_file ... failed' warnings for the real cause
align_diffusers_version(); verify_download_integrity(model_path) Prevention
- Pin a diffusers version matching the model card before starting the server
- Verify checkpoint file sizes/hashes after download; retry interrupted snapshots
- Prefer diffusers repo-layout models (model_index.json) over raw single-file checkpoints
- Always read the per-strategy WARNING logs before debugging the final RuntimeError
When it happens
Trigger: Loading a single-file checkpoint (.safetensors/.ckpt) with a diffusers version lacking or breaking from_single_file support for that class; a model directory in an unexpected format (missing model_index.json); corrupted weights; wrong pipeline class guesses for the architecture; out-of-memory during .to(device) after load attempts.
Common situations: diffusers major-version upgrades changing from_single_file kwargs/behavior; SDXL/Flux checkpoints needing newer diffusers than pinned; downloading only part of a repo (interrupted snapshot); mixing safetensors-only expectations with pickle checkpoints.
Related errors
- Remote Windows Diffusers serving is not supported yet; use l
- {type(_pipe).__name__} does not support image edits. Use /v1
AI-assisted analysis of odysseus-dev/odysseus@f9235ebbf1 (2026-08-14).
Data as JSON: /api/errors/935d82bbb3ed1e56.
Report an issue: GitHub.