Skip to main content

Module ort_environment

Module ort_environment 

Source
Expand description

ONNX Runtime global environment: single init per process, runtime dylib loading.

With the load-dynamic Cargo feature (always enabled in lean-ctx’s ort dependency), libonnxruntime is loaded at runtime via ort::init_from. This module resolves the library path across platforms, including NixOS.

§Search order

  1. ORT_DYLIB_PATH env var (resolved relative to the executable directory)
  2. The lean-ctx managed runtime (lean-ctx embeddings provision, GH #732) — version-matched to this build’s ort API level by construction
  3. Nix profile paths (Linux):
    • /run/current-system/sw/lib/ (system profile)
    • /etc/profiles/per-user/$USER/lib/ (NixOS Home Manager per-user)
    • ~/.nix-profile/lib/ (legacy user profile symlink)
  4. Well-known system directories per platform, including the active HOMEBREW_PREFIX and the standard Homebrew/Linuxbrew lib dirs
  5. LD_LIBRARY_PATH / DYLD_LIBRARY_PATH

If no copy is found, ensure_ort_env returns an eager error — session creation hangs rather than failing, so we fail fast.

Functions§

ensure_ort_env
Ensure the global ONNX Runtime environment is initialized.