WasmEdge / mediapipe-rs

The Google mediapipe AI library. Write AI inference applications for image recognition, text classification, audio / video processing and more, in Rust and run them in the secure WasmEdge sandbox. Zero Python dependency!
Apache License 2.0
157 stars 17 forks source link

error: could not compile `mediapipe-rs` #6

Closed aqq777 closed 5 months ago

aqq777 commented 7 months ago

rust version: rustc 1.77.1 (7cf61ebde 2024-03-27) rustup default :stable-x86_64-unknown-linux-gnu (default) wasmedge version 0.13.5 OS: ubuntu 22.04

After cloning the code from github, I run the command as follow: cargo run --release --example image_classification -- ./assets/models/image_classification/efficientnet_lite0_fp32.tflite ./assets/testdata/img/burger.jpg

then I got such message, how to fix these errros?

 Updating crates.io index
    Updating git repository `https://github.com/yanghaku/rust-ffmpeg.git`
  Downloaded extended v0.1.0
  Downloaded symphonia v0.5.4
  Downloaded symphonia-format-riff v0.5.4
  Downloaded symphonia-codec-pcm v0.5.4
  Downloaded symphonia-metadata v0.5.4
  Downloaded encoding_rs v0.8.33
  Downloaded 6 crates (1.4 MB) in 1.36s (largest was `encoding_rs` at 1.4 MB)
    Blocking waiting for file lock on package cache
   Compiling autocfg v1.2.0
   Compiling libm v0.2.8
   Compiling bytemuck v1.15.0
   Compiling cfg-if v1.0.0
   Compiling proc-macro2 v1.0.79
   Compiling semver v1.0.22
   Compiling unicode-ident v1.0.12
   Compiling bitflags v1.3.2
   Compiling wasi v0.11.0+wasi-snapshot-preview1
   Compiling arrayvec v0.7.4
   Compiling lazy_static v1.4.0
   Compiling log v0.4.21
   Compiling getrandom v0.2.14
   Compiling paste v1.0.14
   Compiling safe_arch v0.7.1
   Compiling rand_core v0.6.4
   Compiling symphonia-core v0.5.4
   Compiling ppv-lite86 v0.2.17
   Compiling num-traits v0.2.18
   Compiling num-bigint v0.4.4
   Compiling num-rational v0.4.1
   Compiling matrixmultiply v0.3.8
   Compiling typenum v1.17.0
   Compiling rand_chacha v0.3.1
   Compiling quote v1.0.35
   Compiling syn v2.0.58
   Compiling rustc_version v0.4.0
   Compiling wide v0.7.15
   Compiling ttf-parser v0.20.0
   Compiling memchr v2.7.2
   Compiling rawpointer v0.2.1
   Compiling zune-core v0.4.12
   Compiling num-integer v0.1.46
   Compiling num-complex v0.4.5
   Compiling approx v0.5.1
   Compiling thiserror v1.0.58
   Compiling ab_glyph_rasterizer v0.1.8
   Compiling num-iter v0.1.44
   Compiling zune-jpeg v0.4.11
   Compiling aho-corasick v1.1.3
   Compiling owned_ttf_parser v0.20.0
   Compiling simba v0.8.1
   Compiling flatbuffers v23.5.26
   Compiling thiserror-impl v1.0.58
   Compiling rand v0.8.5
   Compiling encoding_rs v0.8.33
   Compiling regex-syntax v0.8.3
   Compiling ttf-parser v0.15.2
   Compiling byteorder v1.5.0
   Compiling custom_derive v0.1.7
   Compiling either v1.10.0
   Compiling itertools v0.12.1
   Compiling owned_ttf_parser v0.15.2
   Compiling regex-automata v0.4.6
   Compiling conv v0.3.3
   Compiling image v0.25.1
   Compiling symphonia-metadata v0.5.4
   Compiling rand_distr v0.4.3
   Compiling ab_glyph v0.2.24
   Compiling num v0.4.1
   Compiling mediapipe-rs v0.1.0-dev (/home/magee/mj/study/rust_wasm/AI_inference/mediapipe solutions/demo-object-detection/mediapipe-rs)
   Compiling extended v0.1.0
   Compiling symphonia-format-riff v0.5.4
   Compiling nalgebra v0.32.5
   Compiling regex v1.10.4
   Compiling wasi-nn v0.6.0
   Compiling rusttype v0.9.3
   Compiling symphonia-codec-pcm v0.5.4
   Compiling symphonia v0.5.4
   Compiling imageproc v0.24.0
error[E0277]: `Rc<ttf_parser::Face<'static>>` cannot be shared between threads safely
  --> src/postprocess/utils/vision/default_font/mod.rs:10:1
   |
10 | / lazy_static::lazy_static! {
11 | |     static ref DEFAULT_FONT: Font<'static> = Font::try_from_bytes(DEFAULT_FONT_BYTES).unwrap();
12 | |     //static ref DEFAULT_FONT = FontRef::try_from_slice(DEFAULT_FONT_BYTES).unwrap();
13 | | }
   | |_^ `Rc<ttf_parser::Face<'static>>` cannot be shared between threads safely
   |
   = help: within `Font<'static>`, the trait `Sync` is not implemented for `Rc<ttf_parser::Face<'static>>`, which is required by `Font<'static>: Sync`
note: required because it appears within the type `Font<'static>`
  --> /home/magee/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rusttype-0.9.3/src/font.rs:31:10
   |
31 | pub enum Font<'a> {
   |          ^^^^
note: required by a bound in `Lazy`
  --> /home/magee/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lazy_static-1.4.0/src/inline_lazy.rs:19:20
   |
19 | pub struct Lazy<T: Sync>(Cell<Option<T>>, Once);
   |                    ^^^^ required by this bound in `Lazy`
   = note: this error originates in the macro `__lazy_static_create` which comes from the expansion of the macro `lazy_static::lazy_static` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: `Rc<owned_ttf_parser::owned::OwnedFace>` cannot be shared between threads safely
  --> src/postprocess/utils/vision/default_font/mod.rs:10:1
   |
10 | / lazy_static::lazy_static! {
11 | |     static ref DEFAULT_FONT: Font<'static> = Font::try_from_bytes(DEFAULT_FONT_BYTES).unwrap();
12 | |     //static ref DEFAULT_FONT = FontRef::try_from_slice(DEFAULT_FONT_BYTES).unwrap();
13 | | }
   | |_^ `Rc<owned_ttf_parser::owned::OwnedFace>` cannot be shared between threads safely
   |
   = help: within `Font<'static>`, the trait `Sync` is not implemented for `Rc<owned_ttf_parser::owned::OwnedFace>`, which is required by `Font<'static>: Sync`
note: required because it appears within the type `Font<'static>`
  --> /home/magee/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rusttype-0.9.3/src/font.rs:31:10
   |
31 | pub enum Font<'a> {
   |          ^^^^
note: required by a bound in `Lazy`
  --> /home/magee/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lazy_static-1.4.0/src/inline_lazy.rs:19:20
   |
19 | pub struct Lazy<T: Sync>(Cell<Option<T>>, Once);
   |                    ^^^^ required by this bound in `Lazy`
   = note: this error originates in the macro `__lazy_static_create` which comes from the expansion of the macro `lazy_static::lazy_static` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: `Rc<ttf_parser::Face<'static>>` cannot be shared between threads safely
  --> src/postprocess/utils/vision/default_font/mod.rs:10:1
   |
10 | / lazy_static::lazy_static! {
11 | |     static ref DEFAULT_FONT: Font<'static> = Font::try_from_bytes(DEFAULT_FONT_BYTES).unwrap();
12 | |     //static ref DEFAULT_FONT = FontRef::try_from_slice(DEFAULT_FONT_BYTES).unwrap();
13 | | }
   | |_^ `Rc<ttf_parser::Face<'static>>` cannot be shared between threads safely
   |
   = help: within `Font<'static>`, the trait `Sync` is not implemented for `Rc<ttf_parser::Face<'static>>`, which is required by `Font<'static>: Sync`
note: required because it appears within the type `Font<'static>`
  --> /home/magee/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rusttype-0.9.3/src/font.rs:31:10
   |
31 | pub enum Font<'a> {
   |          ^^^^
note: required by a bound in `Lazy::<T>::INIT`
  --> /home/magee/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lazy_static-1.4.0/src/inline_lazy.rs:21:9
   |
21 | impl<T: Sync> Lazy<T> {
   |         ^^^^ required by this bound in `Lazy::<T>::INIT`
22 |     #[allow(deprecated)]
23 |     pub const INIT: Self = Lazy(Cell::new(None), ONCE_INIT);
   |               ---- required by a bound in this associated constant
   = note: this error originates in the macro `__lazy_static_create` which comes from the expansion of the macro `lazy_static::lazy_static` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: `Rc<owned_ttf_parser::owned::OwnedFace>` cannot be shared between threads safely
  --> src/postprocess/utils/vision/default_font/mod.rs:10:1
   |
10 | / lazy_static::lazy_static! {
11 | |     static ref DEFAULT_FONT: Font<'static> = Font::try_from_bytes(DEFAULT_FONT_BYTES).unwrap();
12 | |     //static ref DEFAULT_FONT = FontRef::try_from_slice(DEFAULT_FONT_BYTES).unwrap();
13 | | }
   | |_^ `Rc<owned_ttf_parser::owned::OwnedFace>` cannot be shared between threads safely
   |
   = help: within `Font<'static>`, the trait `Sync` is not implemented for `Rc<owned_ttf_parser::owned::OwnedFace>`, which is required by `Font<'static>: Sync`
note: required because it appears within the type `Font<'static>`
  --> /home/magee/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rusttype-0.9.3/src/font.rs:31:10
   |
31 | pub enum Font<'a> {
   |          ^^^^
note: required by a bound in `Lazy::<T>::INIT`
  --> /home/magee/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lazy_static-1.4.0/src/inline_lazy.rs:21:9
   |
21 | impl<T: Sync> Lazy<T> {
   |         ^^^^ required by this bound in `Lazy::<T>::INIT`
22 |     #[allow(deprecated)]
23 |     pub const INIT: Self = Lazy(Cell::new(None), ONCE_INIT);
   |               ---- required by a bound in this associated constant
   = note: this error originates in the macro `__lazy_static_create` which comes from the expansion of the macro `lazy_static::lazy_static` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0277`.
error: could not compile `mediapipe-rs` (lib) due to 4 previous errors
warning: build failed, waiting for other jobs to finish...
Moon1102 commented 5 months ago

Rc<ttf_parser::Face<'static>>` cannot be shared between threads safely This error, actually, it's because the rusttype used by this library doesn't use the has-atomics feature.

But even after fixing this problem, it doesn't compile successfully on Rust version 1.78

hydai commented 5 months ago

Hi @yanghaku Could you please check this issue?