Possibility to statically link onnxruntime
beqabeqa473 opened this issue · comments
Hello.
Is there a possibility to statically link onnxruntime with ORT rust crate?
Thanks.
Yes, just compile ONNX Runtime from source and point ort
to the build output. The new v2 branch provides precompiled static libraries as well.
i have a static library, which contains everything inside.
i put it in onnx/onnxruntime.lib
i've set a variable
set ORT_STRATEGY=system
set ORT_LIB_LOCATION=E:\temp\onnx
it is still trying to load library dynamically
Try putting it in a new lib
folder: E:\temp\onnx\lib
(keep the ORT_LIB_LOCATION
the same)
For v1.16, you may also have to create an empty include
folder alongside it (E:\temp\onnx\include
) - this is a known issue that was fixed in v2.0
ok, did onnx\lib\onnxruntime.lib, onnx\include
Should i put something in cargo?
It is default_feature=false for now.
No other Cargo features are required.
then for some reason it is not working
Please upload the output from cargo build
.
There are no errors, only compilation stuff. When i am trying to run a result, it is trying to load onnxruntime.dll near the executable
What command did you use to compile the static library?
i downloaded it from here.
https://github.com/csukuangfj/onnxruntime-build
looking to size, it seems it is static, 242 mb
Hmm, try this one: https://parcel.pyke.io/v2/delivery/ortrs/packages/msort-binary/1.16.2/ortrs-msort_static-v1.16.2-x86_64-pc-windows-msvc.zip
What is the error you get at runtime? Just to make sure, the load-dynamic
feature is disabled (or default-features = false
), correct?
error is the same, could not load library onnxruntime.dll, in cargo default_feature is false, no other libraries are present.
Please upload a screenshot or log file or other media that shows the error in its entirety.
What version of ort
do you have specified, v1.16 or v2? I cannot reproduce this with either.
i have v1.16.3
Unfortunately, for now i am not able to upload a screenshot.
E:\testproj\target\release>testproj.exe
thread '' panicked at C:\Users\beqap.cargo\registry\src\index.crates.io-6f17d22bba15001f\ort-1.16.3\src\lib.rs:79:83:
could not load the library at E:\testproj\target\release/onnxruntime.dll
: LoadLibraryExW { source: Os { code: 126, kind: Uncategorized, message: "The specified module could not be found." } }
note: run with RUST_BACKTRACE=1
environment variable to display a backtrace
could not load the library at E:\testproj\target\release/onnxruntime.dll
: LoadLibraryExW { source: Os { code: 126, kind: Uncategorized, message: "The specified module could not be found." } }
The load-dynamic
feature is enabled, either in your Cargo manifest or via a dependency that then depends on ort
.
Yes, you are right. I missed one of dependencies.
Sorry for disturbing and thanks.