Skip to content

Point at a runtime you already have

You have ONNX Runtime installed — from a distribution package, a vendor build, or a compile of your own — and you want the resolver to use it rather than fetch one.

Pass the path

lib, err := resolver.Resolve(ctx, "/usr/lib/x86_64-linux-gnu/libonnxruntime.so")

That is the whole answer. An explicit path outranks every other source and short-circuits the rest of the chain: no cache lookup, no network, no index.

Wire it to configuration

Pass the configured value through unconditionally rather than branching on it. An empty string is the documented way to say decide for me, so the branch you would write is one the resolver already contains:

lib, err := resolver.Resolve(ctx, cfg.ONNXRuntimeLibrary)   // "" when unset

Wire it to the environment

In a container image that already ships the runtime, export the path once and read it in one place:

ENV ONNXRUNTIME_LIB=/usr/local/lib/libonnxruntime.so
lib, err := resolver.Resolve(ctx, os.Getenv("ONNXRUNTIME_LIB"))

Unset, os.Getenv returns "" and the resolver falls through to its normal order — so the same binary works inside the image and on a developer's laptop without a second code path.

The path is not checked

A path you pass is returned as given, even if nothing is there. This is deliberate. The alternative — falling back to the channel when your path does not resolve — means a machine you have configured quietly runs a different runtime from the one you specified, and the mismatch shows up as an inference result rather than an error.

If your path is wrong you get the dynamic loader's complaint about your path, which names the file you meant.

When there is no published build

This is the remedy ErrNoPlatformBuild points at. Upstream dropped macOS Intel between 1.23.0 and 1.26.0, so a machine that once resolved a runtime from the channel gets nothing at a later version. An explicit path is how that machine keeps working — see platform builds.