nbigaouette / onnxruntime-rs

Rust wrapper for Microsoft's ONNX Runtime (version 1.8)
Apache License 2.0
276 stars 99 forks source link

Assert Failed when Initializing Environment #119

Open Rorical opened 1 year ago

Rorical commented 1 year ago

I've tested it successfully on my computer but after I moved it to another machine with WinServer 2022 I got the following error.

DEBUG: onnxruntime::environment: Environment not yet initialized, creating a new one.
thread 'main' panicked at 'assertion failed: `(left != right)`
  left: `0x0`,
 right: `0x0`', C:\Users\Administrator\.cargo\registry\src\github.com-1ecc6299db9ec823\onnxruntime-0.0.14\src\lib.rs:180:5
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library\std\src\panicking.rs:575
   1: core::panicking::panic_fmt
             at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library\core\src\panicking.rs:64
   2: core::fmt::Arguments::new_v1
             at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library\core\src\fmt\mod.rs:398
   3: core::panicking::assert_failed_inner
             at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library\core\src\panicking.rs:245
   4: core::panicking::assert_failed<ptr_mut$<onnxruntime_sys::OrtApi>,ptr_mut$<onnxruntime_sys::OrtApi> >
             at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483\library\core\src\panicking.rs:199
   5: onnxruntime::g_ort
             at C:\Users\Administrator\.cargo\registry\src\github.com-1ecc6299db9ec823\onnxruntime-0.0.14\src\lib.rs:180
   6: onnxruntime::environment::Environment::new
             at C:\Users\Administrator\.cargo\registry\src\github.com-1ecc6299db9ec823\onnxruntime-0.0.14\src\environment.rs:105
   7: onnxruntime::environment::EnvBuilder::build
             at C:\Users\Administrator\.cargo\registry\src\github.com-1ecc6299db9ec823\onnxruntime-0.0.14\src\environment.rs:234

which indicates that this assert failed:

fn g_ort() -> sys::OrtApi {
    let mut api_ref = G_ORT_API
        .lock()
        .expect("Failed to acquire lock: another thread panicked?");
    let api_ref_mut: &mut *mut sys::OrtApi = api_ref.get_mut();
    let api_ptr_mut: *mut sys::OrtApi = *api_ref_mut;

    assert_ne!(api_ptr_mut, std::ptr::null_mut());

    unsafe { *api_ptr_mut }
}

I have no experience with the onnx runtime lib so I was wondering if is that system related or if some dependencies are missing. Any help is appreciated.

Rorical commented 1 year ago

I just noticed that this project is unmaintained and switched to ORT, which is based on this project. The README says that the program will depend on the default windows onnx runtime in the system32 folder, and this may vary on different devices. So the best way is to include onnx runtime lib in distribution.