Closed PierreLouisLetoquart closed 3 hours ago
Note: I used a model from onnx-community on HG
git clone https://huggingface.co/onnx-community/depth-anything-v2-small
cp depth-anything-v2-small/onnx/model.onnx /path/to/test/repo
libstdc++6
is required since ONNX Runtime is a C++ library. It seems the package is not installed by default on the minideb
image.
Thanks so much for the reactivity! Which image do you recommend for that usecase ? I've naivly tested to install libstdc++6 on the current one but it doesn't work
It doesn't work ! I've tried various way, the "just install gcc" produces the same error output:
FROM rust:1.82-slim-bullseye AS builder
WORKDIR /code
RUN apt-get update && \
apt-get install -y \
gcc
RUN USER=root cargo init
COPY Cargo.toml Cargo.lock ./
RUN cargo fetch
COPY src src
COPY model.onnx model.onnx
RUN cargo build --release
# run stage
FROM bitnami/minideb:latest
WORKDIR /app
COPY --from=builder /code/model.onnx model.onnx
COPY --from=builder /code/target/release/ort-test ort-test
USER 1001
CMD [ "/app/ort-test" ]
Installing libstdc++-10-dev
might help. Its probably missing the .a
files.
It is a little bit better (maybe, not sure lol) but I've a long af error trace rn
Try libstdc++-12-dev
Does it requires somthing like:
fn main() {
println!("cargo:rustc-link-lib=dylib=stdc++");
}
Never deal with that type of things ://
> [builder 3/9] RUN apt-get update && apt-get install -y libstdc++-12-dev:
0.152 Get:1 http://deb.debian.org/debian bullseye InRelease [116 kB]
0.188 Get:2 http://deb.debian.org/debian-security bullseye-security InRelease [27.2 kB]
0.201 Get:3 http://deb.debian.org/debian bullseye-updates InRelease [44.1 kB]
0.240 Get:4 http://deb.debian.org/debian bullseye/main arm64 Packages [7955 kB]
0.455 Get:5 http://deb.debian.org/debian-security bullseye-security/main arm64 Packages [301 kB]
0.461 Get:6 http://deb.debian.org/debian bullseye-updates/main arm64 Packages [16.3 kB]
1.110 Fetched 8460 kB in 1s (8447 kB/s)
1.110 Reading package lists...
1.449 Reading package lists...
1.782 Building dependency tree...
1.851 Reading state information...
1.909 E: Unable to locate package libstdc++-12-dev
1.909 E: Couldn't find any package by regex 'libstdc++-12-dev'
Oh, how fun, minideb:latest
isn't actually latest, but based on bullseye. The ONNX Runtime binaries provided by ort
are built on Ubuntu 22.04 and thus require something closer to bookworm
; try using bitnami/minideb:bookworm
instead, or a non-minimal container like cimg/rust
just to verify everything else works and then working backwards from there.
Can you use debian bookworm
instead of bullseye
(it has libstdc++-12-dev
)?
I'll do that
Works perfectly, requires to manually add libstdc++-12-dev
Dockerfile:
FROM rust:1.82-slim-bookworm AS builder
WORKDIR /code
RUN apt-get update && \
apt-get install -y \
libstdc++-12-dev
RUN USER=root cargo init
COPY Cargo.toml Cargo.lock ./
RUN cargo fetch
COPY src src
COPY model.onnx model.onnx
RUN cargo build --release
# run stage
FROM bitnami/minideb:bookworm
WORKDIR /app
COPY --from=builder /code/model.onnx model.onnx
COPY --from=builder /code/target/release/ort-test ort-test
USER 1001
CMD [ "/app/ort-test" ]
Or no need to manually add libstdc++-12-dev
with (none slim) bookworm
. Thanks @audioXD , @decahedron1 sooo much
Bug Report: [Error] When Building Docker img:
ld returned 1 exit status
Description
I encountered an error when attempting to build a Docker image for my Rust project using the
ort
dependency with version2.0.0-rc.8
, The script build a session with the./model.onnx
file.Steps to Reproduce
Set up the
Cargo.toml
file with the following dependencies:Load a local onnx model with the following code in
src/main.rs
:Use the following
Dockerfile
:Run the Docker build command:
Expected Behavior
The Docker image should be built successfully with the
ort-test
executable included.Actual Behavior
The build fails with the following error trace (collapsed for readability):
Build Error Trace
```bash [+] Building 12.9s (16/18) docker:desktop-linux => [internal] load build definition from Dockerfile 0.0s => => transferring dockerfile: 417B 0.0s => [internal] load metadata for docker.io/bitnami/minideb:latest 0.4s => [internal] load metadata for docker.io/library/rust:1.82-slim-bullseye 0.4s => [auth] library/rust:pull token for registry-1.docker.io 0.0s => [auth] bitnami/minideb:pull token for registry-1.docker.io 0.0s => [internal] load .dockerignore 0.0s => => transferring context: 105B 0.0s => [builder 1/8] FROM docker.io/library/rust:1.82-slim-bullseye@sha256:36fa9bec836e763bb4456e7cdba6a2115e334c99ad4510db1cf205e49dc13e0e 0.0s => [stage-1 1/3] FROM docker.io/bitnami/minideb:latest@sha256:6bcaf017181f0b3f8196ace16df8176bf926bdcc08ff347793109f2547a841e8 0.0s => [internal] load build context 0.0s => => transferring context: 265B 0.0s => CACHED [builder 2/8] WORKDIR /code 0.0s => CACHED [builder 3/8] RUN USER=root cargo init 0.0s => CACHED [builder 4/8] COPY Cargo.toml Cargo.toml 0.0s => CACHED [builder 5/8] COPY model.onnx model.onnx 0.0s => CACHED [builder 6/8] RUN cargo fetch 0.0s => CACHED [builder 7/8] COPY src src 0.0s => ERROR [builder 8/8] RUN cargo build --release 12.5s ------ > [builder 8/8] RUN cargo build --release: 0.446 Compiling libc v0.2.161 0.446 Compiling cfg-if v1.0.0 0.446 Compiling shlex v1.3.0 0.446 Compiling typenum v1.17.0 0.446 Compiling version_check v0.9.5 0.447 Compiling autocfg v1.4.0 0.447 Compiling tinyvec_macros v0.1.1 0.447 Compiling rustls-pki-types v1.10.0 0.575 Compiling tinyvec v1.8.0 0.575 Compiling rustix v0.38.37 0.712 Compiling cc v1.1.31 0.764 Compiling generic-array v0.14.7 0.876 Compiling untrusted v0.9.0 0.896 Compiling spin v0.9.8 0.905 Compiling unicode-bidi v0.3.17 0.931 Compiling linux-raw-sys v0.4.14 0.939 Compiling percent-encoding v2.3.1 0.963 Compiling rustls v0.23.15 1.021 Compiling bitflags v2.6.0 1.053 Compiling form_urlencoded v1.2.1 1.138 Compiling num-traits v0.2.19 1.161 Compiling zeroize v1.8.1 1.244 Compiling adler2 v2.0.0 1.271 Compiling once_cell v1.20.2 1.304 Compiling unicode-normalization v0.1.24 1.329 Compiling log v0.4.22 1.329 Compiling subtle v2.6.1 1.381 Compiling byteorder v1.5.0 1.404 Compiling miniz_oxide v0.8.0 1.497 Compiling getrandom v0.2.15 1.522 Compiling socks v0.3.4 1.522 Compiling filetime v0.2.25 1.584 Compiling cpufeatures v0.2.14 1.620 Compiling webpki-roots v0.26.6 1.628 Compiling crc32fast v1.4.2 1.687 Compiling base64 v0.22.1 1.715 Compiling idna v0.5.0 1.768 Compiling flate2 v1.0.34 1.840 Compiling ring v0.17.8 1.871 Compiling crypto-common v0.1.6 1.910 Compiling block-buffer v0.10.4 1.929 Compiling matrixmultiply v0.3.9 1.946 Compiling pkg-config v0.3.31 1.973 Compiling digest v0.10.7 2.069 Compiling url v2.5.2 2.096 Compiling sha2 v0.10.8 2.221 Compiling rawpointer v0.2.1 2.278 Compiling tracing-core v0.1.32 2.335 Compiling num-integer v0.1.46 2.345 Compiling num-complex v0.4.6 2.489 Compiling pin-project-lite v0.2.14 2.529 Compiling half v2.4.1 2.658 Compiling tracing v0.1.40 2.738 Compiling xattr v1.3.1 2.778 Compiling ndarray v0.16.1 2.878 Compiling tar v0.4.42 3.816 Compiling rustls-webpki v0.102.8 6.250 Compiling ureq v2.10.1 6.781 Compiling ort-sys v2.0.0-rc.8 10.49 Compiling ort v2.0.0-rc.8 12.00 Compiling ort-test v0.1.0 (/code) 12.33 error: linking with `cc` failed: exit status: 1 12.33 | 12.33 = note: LC_ALL="C" PATH="/usr/local/rustup/toolchains/1.82.0-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/bin:/usr/local/rustup/toolchains/1.82.0-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/bin:/usr/local/rustup/toolchains/1.82.0-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/bin:/usr/local/cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" VSLANG="1033" "cc" "/tmp/rustcV4s3VK/symbols.o" "/code/target/release/deps/ort_test-c05537a8f0a8171b.ort_test.f793ec45b8c166e7-cgu.0.rcgu.o" "/code/target/release/deps/ort_test-c05537a8f0a8171b.ort_test.f793ec45b8c166e7-cgu.1.rcgu.o" "/code/target/release/deps/ort_test-c05537a8f0a8171b.ort_test.f793ec45b8c166e7-cgu.2.rcgu.o" "/code/target/release/deps/ort_test-c05537a8f0a8171b.ort_test.f793ec45b8c166e7-cgu.3.rcgu.o" "/code/target/release/deps/ort_test-c05537a8f0a8171b.ort_test.f793ec45b8c166e7-cgu.4.rcgu.o" "/code/target/release/deps/ort_test-c05537a8f0a8171b.2ct6k0b48srmn0n4p7irsxkcd.rcgu.o" "-Wl,--as-needed" "-Wl,-Bstatic" "/code/target/release/deps/libort-3d08ad875e8508ae.rlib" "/code/target/release/deps/libhalf-beb18ee1785c06d7.rlib" "/code/target/release/deps/libcfg_if-0026b015111e6727.rlib" "/code/target/release/deps/libndarray-5e72d2a0bf2f0ba0.rlib" "/code/target/release/deps/libmatrixmultiply-10aec57730c4ed56.rlib" "/code/target/release/deps/libnum_complex-ef1e2765bc91fc92.rlib" "/code/target/release/deps/libnum_integer-5354220c7654582a.rlib" "/code/target/release/deps/libnum_traits-73652e01c77e8fac.rlib" "/code/target/release/deps/librawpointer-8819c9b379461dac.rlib" "/code/target/release/deps/libtracing-510210d23f5dbd2c.rlib" "/code/target/release/deps/libpin_project_lite-43b02254a7e5d1bb.rlib" "/code/target/release/deps/libtracing_core-fa7fa346ba696018.rlib" "/code/target/release/deps/libonce_cell-07ee111a0d049f56.rlib" "/code/target/release/deps/libort_sys-199844376b12802e.rlib" "/usr/local/rustup/toolchains/1.82.0-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib/libstd-6dd4704180e83658.rlib" "/usr/local/rustup/toolchains/1.82.0-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib/libpanic_unwind-4e6a2406b4d4238c.rlib" "/usr/local/rustup/toolchains/1.82.0-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib/libobject-14a05d7053312c41.rlib" "/usr/local/rustup/toolchains/1.82.0-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib/libmemchr-bc5d0c2c17f6efb5.rlib" "/usr/local/rustup/toolchains/1.82.0-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib/libaddr2line-d49284e733162194.rlib" "/usr/local/rustup/toolchains/1.82.0-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib/libgimli-399d6d9d480f795b.rlib" "/usr/local/rustup/toolchains/1.82.0-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib/librustc_demangle-5eec563be8d4a86c.rlib" "/usr/local/rustup/toolchains/1.82.0-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib/libstd_detect-b4e863e039c1e2b2.rlib" "/usr/local/rustup/toolchains/1.82.0-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib/libhashbrown-2cba6cb85e41482c.rlib" "/usr/local/rustup/toolchains/1.82.0-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-04818ce3c2111186.rlib" "/usr/local/rustup/toolchains/1.82.0-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib/libminiz_oxide-a9c50009f9caf7a5.rlib" "/usr/local/rustup/toolchains/1.82.0-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib/libadler-14957fef627d3eac.rlib" "/usr/local/rustup/toolchains/1.82.0-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib/libunwind-7fd5a10030b438fd.rlib" "/usr/local/rustup/toolchains/1.82.0-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib/libcfg_if-3ed6823815f7ddfa.rlib" "/usr/local/rustup/toolchains/1.82.0-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib/liblibc-764cf06d9fa7ac52.rlib" "/usr/local/rustup/toolchains/1.82.0-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib/liballoc-02813af72277ddec.rlib" "/usr/local/rustup/toolchains/1.82.0-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib/librustc_std_workspace_core-e4efde0144e702d3.rlib" "/usr/local/rustup/toolchains/1.82.0-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib/libcore-f5a882967048065e.rlib" "/usr/local/rustup/toolchains/1.82.0-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib/libcompiler_builtins-6d60f560e3825be6.rlib" "-Wl,-Bdynamic" "-lstdc++" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/root/.cache/ort.pyke.io/dfbin/aarch64-unknown-linux-gnu/B40AB3EA5BF3BCBC73C18BA66A8F96ECAA9D08963C0D6A5268D608B0642D23D4/onnxruntime/lib" "-L" "/usr/local/rustup/toolchains/1.82.0-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib" "-o" "/code/target/release/deps/ort_test-c05537a8f0a8171b" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-Wl,-O1" "-Wl,--strip-debug" "-nodefaultlibs" 12.33 = note: /usr/bin/ld: cannot find -lstdc++ 12.33 collect2: error: ld returned 1 exit status 12.33 12.33 12.34 error: could not compile `ort-test` (bin "ort-test") due to 1 previous error ------ Dockerfile:11 -------------------- 9 | COPY src src 10 | 11 | >>> RUN cargo build --release 12 | 13 | # run stage -------------------- ERROR: failed to solve: process "/bin/sh -c cargo build --release" did not complete successfully: exit code: 101 View build details: docker-desktop://dashboard/build/desktop-linux/desktop-linux/qtrnjm5fd7zpdmh6wnuog8p2y ```Environment
2.0.0-rc.8
Additional Context
system info: