These instructions require cargo and rustc.
To get these follow the instructions at https://rustup.rs
The instructions compile the onnxruntime along with the bindings,
so require cmake
, a python 3 interpreter, clang (needed to parse the C headers to generate the Rust bindings),
and the platform compiler to compile onnxruntime.
git clone https://github.com/microsoft/onnxruntime
cd onnxruntime
git submodule update --init --recursive
from the root of onnxruntime repo
CARGO_TARGET_DIR=build/rust cargo build --manifest-path rust/Cargo.toml
The CARGO_TARGET_DIR environment variable puts the build artifacts in onnxruntime/build/rust
instead of onnxruntime/rust/target
.
CARGO_TARGET_DIR=build/rust cargo test --manifest-path rust/Cargo.toml --features model-fetching
RUST_ONNXRUNTIME_LIBRARY_PATH=<absolute path to shared library/libonnxruntime.so> CARGO_TARGET_DIR=build/rust cargo test --manifest-path rust/Cargo.toml --features model-fetching
If you are using a nightly Rust compiler and are on one the platforms listed in Rust sanitizer support.
where $SAN
is one of address
, thread
, memory
or leak
RUSTFLAGS="-Zsanitizer=$SAN" CARGO_TARGET_DIR=build/rust cargo test --manifest-path rust/Cargo.toml --features model-fetching --target <your target for example x86_64-unknown-linux-gnu> -Z build-std -- --test-threads=1