Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[C API]: Cannot run generated binary without cargo run / configurable location for ONNX shared library #10

Open
radu-matei opened this issue Jun 22, 2021 · 3 comments
Labels
help wanted Extra attention is needed

Comments

@radu-matei
Copy link
Member

Right now, if you try to run the compiled helper binary wasmtime-onnx, you get the following error:

error loading shared libraries: libonnxruntime.so.1.6.0: cannot open shared object file: No such file or directory

This is because the binary is compiled with the ONNX shared library linked directly from the target/ directory.
See https://github.com/nbigaouette/onnxruntime-rs/blob/master/ONNX_Compilation_Notes.md

@radu-matei radu-matei added the help wanted Extra attention is needed label Jun 22, 2021
@radu-matei radu-matei changed the title Cannot run generated binary without cargo run Cannot run generated binary without cargo run / configurable location for ONNX shared library Jun 22, 2021
@radu-matei
Copy link
Member Author

radu-matei commented Jun 22, 2021

I managed to set the location of the shared library:

  • first, set $ORT_LIB_LOCATION and $ORT_STRATEGY to the location of the local ONNX library and system.
  • compile the binary binary again (the build script of onnxruntime-sys gets triggered when the environment variables change).
  • set $LD_LIBRARY_PATH to the /lib directory of the local ONNX library.
➜ echo $ORT_LIB_LOCATION && echo $ORT_STRATEGY
/home/radu/onnx/onnxruntime-linux-x64-1.6.0
system

➜ cargo build --bin wasmtime-onnx
...

➜ LD_LIBRARY_PATH=/home/radu/onnx/onnxruntime-linux-x64-1.6.0/lib ./target/debug/wasmtime-onnx
error: The following required arguments were not provided:
    <module>

USAGE:
    wasmtime-onnx <module> --invoke <invoke>

This is fine for now, but we'll need a way to define this at runtime rather than at compile time, and with a different environment variable.

@radu-matei
Copy link
Member Author

radu-matei commented Jun 22, 2021

The approach taken by the Rust bindings for OpenVINO seems to be exactly what we are looking for - https://github.com/intel/openvino-rs/tree/main/crates/openvino-sys/src/linking

Also see chertov/onnxruntime-rs@b94870f

@radu-matei radu-matei changed the title Cannot run generated binary without cargo run / configurable location for ONNX shared library [C API]: Cannot run generated binary without cargo run / configurable location for ONNX shared library Jun 24, 2021
@radu-matei
Copy link
Member Author

Documenting that expanding the LD_LIBRARY_PATH environment variable solves this issue should be enough to close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant