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

Openblas support on Macosx M1 #1171

Closed
poqudrof opened this issue Apr 14, 2022 · 9 comments
Closed

Openblas support on Macosx M1 #1171

poqudrof opened this issue Apr 14, 2022 · 9 comments

Comments

@poqudrof
Copy link
Contributor

Hello,

I currently struggle with an ugly yet familiar issue, the library cannot load :

UnsatisfiedLinkError: no jniopenblas_nolapack in java.library.path:

I managed to install openblas to the current "stable" version supported by Javacpp presets :  0.3.19, with javaCPP 1.5.7.

With the example code, at version 1.5.7, I get this error (which may not be exactly the same) :

LAPACKE_dgels (row-major, high-level) Example Program Results
[WARNING] 
java.lang.UnsatisfiedLinkError: 'int org.bytedeco.openblas.global.openblas.LAPACKE_dgels(int, byte, int, int, int, double[], int, double[], int)'
    at org.bytedeco.openblas.global.openblas.LAPACKE_dgels (Native Method)
    at ExampleDGELSrowmajor.main (ExampleDGELSrowmajor.java:122)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:254)
    at java.lang.Thread.run (Thread.java:833)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.717 s
[INFO] Finished at: 2022-04-14T17:34:49+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.0.0:java (default-cli) on project openblas: An exception occured while executing the Java class. 'int org.bytedeco.openblas.global.openblas.LAPACKE_dgels(int, byte, int, int, int, double[], int, double[], int)' -> [Help 1]

I use Java 17 and want to work with OpenCV in Processing 4 on my Mac. By default Opencv 4.5.5 on OSX comes with Openblas 0.3.20.

The Openblas_nolapack code does have any macosx-arm64 specific code, so maybe it fails at loading some dependencies ?

It is / was reported to work on OSX there #1069 . I saw the other issues with Openblas there bytedeco/javacv#1435, I guess it is not an easy dependency to work with.

Do you have an idea to solve this ?

Cheers,

Jeremy.

@saudet
Copy link
Member

saudet commented Apr 14, 2022 via email

@devjeonghwan
Copy link
Member

devjeonghwan commented Apr 16, 2022

I'm not sure but, Maybe you can build openblas contains lapack/fortran using below repository.

https://github.com/iains/gcc-darwin-arm64
https://github.com/fxcoudert/gfortran-for-macOS/releases/tag/12-arm-alpha

@poqudrof
Copy link
Contributor Author

But LAPACK does compile from homebrew, this one did compile fine on my laptop: https://formulae.brew.sh/formula/openblas .

@saudet
Copy link
Member

saudet commented Apr 22, 2022

It's possible gfortran is now available, yes. Please give it a try by updating the build script and see what that gives.

@saudet
Copy link
Member

saudet commented Apr 22, 2022

Oh, pull OpenMathLib/OpenBLAS#3539 is something interesting that got merged recently. I'll give that a try when 0.3.21 gets released, but contributions are always welcome, so if you make it work before the release, please open a pull request with the necessary changes! Thank you

@poqudrof
Copy link
Contributor Author

poqudrof commented Jun 8, 2022

So, after quite some time I am back at it.

I managed to compile the preset for 0.3.20 and JavacCPP 1.5.7 without any code modification.
The problem was my Java version which was only for macosx-x86_64 and not for arm64.

The included example does not work though, impossible to find LAPACK_ROW_MAJOR.

I use the code with Processing, and there is now a Processing version that uses arm64 🥳.

No issue left for me here, it should all go smoothly once the next release is done.
Thanks for the support ! 
Jeremy.

@poqudrof poqudrof closed this as completed Jun 8, 2022
@saudet
Copy link
Member

saudet commented Jun 9, 2022

The included example does not work though, impossible to find LAPACK_ROW_MAJOR.

Let's keep this issue open for that.

@saudet saudet reopened this Jun 9, 2022
saudet added a commit that referenced this issue Aug 9, 2022
… PyTorch 1.12.1, DepthAI 2.17.2, ONNX Runtime 1.12.1, OpenSSL 3.0.5
saudet added a commit that referenced this issue Aug 11, 2022
… PyTorch 1.12.1, DepthAI 2.17.2, ONNX Runtime 1.12.1, OpenSSL 3.0.5
@saudet
Copy link
Member

saudet commented Aug 11, 2022

It's done! With commit 7d9084f LAPACK is now available for ARM on Android, iOS, Mac, etc.
Please give it a try with the snapshots: http://bytedeco.org/builds/

@saudet
Copy link
Member

saudet commented Nov 3, 2022

This has now been released with version 1.5.8. Enjoy!

@saudet saudet closed this as completed Nov 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants