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
ORT_DYLIB_PATHenv var (resolved relative to the executable directory)- Nix profile paths —
/run/current-system/sw/lib/,~/.nix-profile/lib/(Linux) - Well-known system directories per platform, including the active
HOMEBREW_PREFIXand the standard Homebrew/Linuxbrew lib dirs 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.