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. Nix profile paths — /run/current-system/sw/lib/, ~/.nix-profile/lib/ (Linux)
  3. Well-known system directories per platform, including the active HOMEBREW_PREFIX and the standard Homebrew/Linuxbrew lib dirs
  4. 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.