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

Rust flags are needed for compiling and using on linux #35

Open
krlohnes opened this issue Oct 29, 2020 · 6 comments
Open

Rust flags are needed for compiling and using on linux #35

krlohnes opened this issue Oct 29, 2020 · 6 comments

Comments

@krlohnes
Copy link
Contributor

This target is specifically for OSX, but if you're trying to build onnx and run with this lib on Linux, it seems like it needs to be there as well.

I can push up a PR for this, but I don't know if you want to add it for Linux or remove the target. Both fixed the issues I had using a compiled onnx with my rust project, but I'm not familiar enough yet with the impact it might have for other platforms you're targeting.

@krlohnes krlohnes changed the title Rust flags are needed for any compiling and using on linux Rust flags are needed for compiling and using on linux Oct 29, 2020
@nbigaouette
Copy link
Owner

I think I've added this "back then" to try to fix the rpath issue on macOS. I think I wanted to be able to run the binary directly without going through cargo. For this I wanted the compile binary to include the path to the lib. On linux I think this is possible but not on macOS; the file might not even have the desired effect on macOS!

I'll try tonight if the file is still required.

What is your exact use case?

@krlohnes
Copy link
Contributor Author

I'm trying to create a docker image for my rust project, and compile onnx in that dockerfile and use that compiled version with it.

I have the use case working on OSX on my dev machine, and this has been working well so far.

The docker file looks something like.

FROM rust:1 AS build
RUN apt-get update && apt-get cmake libgomp1 locales locales-all clang -y
RUN locale-gen en_US.UTF-8
RUN update-locale LANG=en_US.UTF-8

WORKDIR /usr/src
RUN git clone https://github.com/microsoft/onnxruntime.git onnxruntime
RUN USER=root cargo new my-app
RUN mkdir -p /usr/src/my-app/target/onnxruntime
WORKDIR /usr/src/onnxruntime
RUN git checkout v1.5.2
RUN ./build.sh --config RelWithDebInfo --build_shared_lib --parallel --cmake_extra_defines="CMAKE_INSTALL_PREFIX=/usr/src/my-app/target/onnxruntime"

WORKDIR build/Linux/RelWithDebInfo
RUN make install
WORKDIR /usr/src/my-app
COPY Cargo.toml Cargo.lock ./
COPY src ./src
ENV ONNXRUNTIME_INSTALL_DIR=/usr/src/my-app/target/onnxruntime
ENV ORT_LIB_LOCATION=/usr/src/my-app/target/onnxruntime
ENV ORT_STRATEGY=system
RUN cargo build --release

I'll admit, I'm relatively new to onnx and just slightly less new to Rust, so any advice you might have would be great.

@krlohnes
Copy link
Contributor Author

I'd been following the compilation notes for reference

@nbigaouette
Copy link
Owner

I'll take a closer look tonight.

Meanwhile, have you tried letting the crate download the pre-built version automatically? That might same a lot of compile time :D But be it compiled or pre-built, both should work fine...

@krlohnes
Copy link
Contributor Author

I've used the prebuilt successfully and it sure did save a lot of compile time. 😂 I'm experimenting with various build flags at the moment and that's where this came in to play.

@nbigaouette
Copy link
Owner

Note that the markdown notes were from the start of the project. I suspect they are out of date, specially the ONNXRUNTIME_INSTALL_DIR variable which is not used anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants