cocoa-xu / evision

Evision: An OpenCV-Erlang/Elixir binding
https://evision.app
Apache License 2.0
352 stars 22 forks source link

Compilation error on Mac M1 #219

Closed thbar closed 1 year ago

thbar commented 1 year ago

I'm going to start using evision a bit for different experiments. Today I cloned the repo and ran mix test, but I'm facing an error. Reporting it here in case it helps other, but I will likely look into it.

EDIT: my OS is MacOS 13.2.1 (22D68) (Ventura).

$ mix test

# SNIP

16:19:33.737 [info] EVISION_PREFER_PRECOMPILED: true; try to download and use the precompiled library.

16:19:33.738 [info] Current target `aarch64-apple-darwin` has precompiled binaries.

16:19:33.738 [info] Current NIF version `2.16` has precompiled binaries.

16:19:34.906 [info] Precompiled binary tarball downloaded and saved to /Users/thbar/Library/Caches/evision-nif_2.16-aarch64-apple-darwin-contrib-0.1.33.tar.gz, sha256=63b62aca00c2c95d9f70fd36a516dd75a7087a16e2fdc05a5bc837caa34b0295
** (MatchError) no match of right hand side value: {:error, "the precompiled NIF file does not exist in the checksum file. Please consider run: `EVISION_FETCH_PRECOMPILED=true mix evision.fetch --all` to generate the checksum file."}
    mix.exs:601: Mix.Tasks.Compile.EvisionPrecompiled.prepare/7
    (mix 1.15.2) lib/mix/task.ex:447: anonymous fn/3 in Mix.Task.run_task/5
    (mix 1.15.2) lib/mix/tasks/compile.all.ex:124: Mix.Tasks.Compile.All.run_compiler/2
    (mix 1.15.2) lib/mix/tasks/compile.all.ex:104: Mix.Tasks.Compile.All.compile/4
    (mix 1.15.2) lib/mix/tasks/compile.all.ex:93: Mix.Tasks.Compile.All.with_logger_app/2
    (mix 1.15.2) lib/mix/tasks/compile.all.ex:56: Mix.Tasks.Compile.All.run/1
    (mix 1.15.2) lib/mix/task.ex:447: anonymous fn/3 in Mix.Task.run_task/5
    (mix 1.15.2) lib/mix/tasks/compile.ex:141: Mix.Tasks.Compile.run/1
thbar commented 1 year ago

EVISION_FETCH_PRECOMPILED=true mix evision.fetch --all also failed:

❯ EVISION_FETCH_PRECOMPILED=true mix evision.fetch --all
===> Analyzing applications...
===> Compiling telemetry
==> decimal
Compiling 4 files (.ex)
Generated decimal app
==> progress_bar
Compiling 10 files (.ex)
Generated progress_bar app
==> table
Compiling 5 files (.ex)
Generated table app
==> castore
Compiling 1 file (.ex)
Generated castore app
==> elixir_make
Compiling 6 files (.ex)
Generated elixir_make app
==> cc_precompiler
Compiling 3 files (.ex)
Generated cc_precompiler app
==> dll_loader_helper
Compiling 2 files (.ex)
Generated dll_loader_helper app
==> complex
Compiling 2 files (.ex)
Generated complex app
==> nx
Compiling 31 files (.ex)
Generated nx app
==> kino
Compiling 41 files (.ex)
Generated kino app
==> evision
Compiling 30 files (.ex)
error: Evision.FaceRecognizerSF.__struct__/0 is undefined, cannot expand struct Evision.FaceRecognizerSF. Make sure the struct name is correct. If the struct name exists and is correct but it still cannot be found, you likely have cyclic module usage in your code
  lib/zoo/face_recognition/sface.ex:214: Evision.Zoo.FaceRecognition.SFace.match_feature/4

error: Evision.DNN.Net.__struct__/0 is undefined, cannot expand struct Evision.DNN.Net. Make sure the struct name is correct. If the struct name exists and is correct but it still cannot be found, you likely have cyclic module usage in your code
  lib/zoo/image_classification/pp_resnet.ex:112: Evision.Zoo.ImageClassification.PPResNet.infer/3

error: Evision.DNN.Net.__struct__/0 is undefined, cannot expand struct Evision.DNN.Net. Make sure the struct name is correct. If the struct name exists and is correct but it still cannot be found, you likely have cyclic module usage in your code
  lib/zoo/image_classification/mobilenet_v1.ex:112: Evision.Zoo.ImageClassification.MobileNetV1.infer/3

error: Evision.DNN.TextDetectionModelDB.__struct__/0 is undefined, cannot expand struct Evision.DNN.TextDetectionModelDB. Make sure the struct name is correct. If the struct name exists and is correct but it still cannot be found, you likely have cyclic module usage in your code
  lib/zoo/text_detection/db.ex:140: Evision.Zoo.TextDetection.DB.infer/2

error: Evision.FaceDetectorYN.__struct__/0 is undefined, cannot expand struct Evision.FaceDetectorYN. Make sure the struct name is correct. If the struct name exists and is correct but it still cannot be found, you likely have cyclic module usage in your code
  lib/zoo/face_detection/yunet.ex:135: Evision.Zoo.FaceDetection.YuNet.setInputSize/2

error: Evision.DNN.Net.__struct__/0 is undefined, cannot expand struct Evision.DNN.Net. Make sure the struct name is correct. If the struct name exists and is correct but it still cannot be found, you likely have cyclic module usage in your code
  lib/zoo/image_segmentation/pp_humanseg.ex:94: Evision.Zoo.ImageSegmentation.PPHumanSeg.infer/2

error: Evision.DNN.Net.__struct__/0 is undefined, cannot expand struct Evision.DNN.Net. Make sure the struct name is correct. If the struct name exists and is correct but it still cannot be found, you likely have cyclic module usage in your code
  lib/zoo/text_recognition/crnn.ex:131: Evision.Zoo.TextRecognition.CRNN.infer/4

== Compilation error in file lib/zoo/face_recognition/sface.ex ==
** (CompileError) lib/zoo/face_recognition/sface.ex: cannot compile module Evision.Zoo.FaceRecognition.SFace (errors have been logged)
    lib/zoo/face_recognition/sface.ex:214: (module
thbar commented 1 year ago

Trying with export EVISION_PREFER_PRECOMPILED=false as mentioned in the README, currently compiling...

thbar commented 1 year ago

Tests passed this way. I'll keep the issue opened.

cocoa-xu commented 1 year ago

Hi @thbar, this is the intended behaviour, i.e., users should install evision from hex.pm instead of compiling it from Git source. And as documented in the README.md, set EVISION_PREFER_PRECOMPILED env var to false should do it, as what you've found above.

EVISION_FETCH_PRECOMPILED=true mix evision.fetch --all is used for developers to fetch all precompiled binaries on GitHub, compute their sha256sums and publish a new version on hex.pm. It's not the intended command for users to use.

thbar commented 1 year ago

Hi @cocoa-xu! I was happy to pull from git in order to have a closer look at how it works. Thanks for the clarifications!