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

Apple Silicon Support #1069

Open
peterrojs opened this issue Aug 10, 2021 · 24 comments
Open

Apple Silicon Support #1069

peterrojs opened this issue Aug 10, 2021 · 24 comments

Comments

@peterrojs
Copy link

Since there are going to be more and more Apple Silicon computers in the wild, it would make sense to make a JAR for macosx-aarch64

@saudet
Copy link
Member

saudet commented Nov 5, 2021

Thanks to W. Bradford Paley and @oxisto, we now have builds for OpenBLAS, OpenCV, and LLVM!

Please give it a try with the snapshots: http://bytedeco.org/builds/

@TimKieu
Copy link

TimKieu commented Nov 29, 2021

For FFMPEG, I found this build for Mac M1: ffmpeg Apple silicon.
Please take a look and integrate in the presets.

@saudet
Copy link
Member

saudet commented Nov 30, 2021

In the case of FFmpeg, we also need to build the dependencies, so that means "porting" all of this:
https://github.com/bytedeco/javacpp-presets/blob/master/ffmpeg/cppbuild.sh#L1322-L1426
It's probably not a huge amount of work, but someone has to do it and contributions are welcome!
Please open a pull request: https://github.com/bytedeco/javacpp-presets/pulls

@saudet
Copy link
Member

saudet commented Jan 21, 2022

I've introduced macosx-arm64 builds for FFmpeg in commit e38c9d1.
Please give it a try with the snapshots: http://bytedeco.org/builds/

@bradh bradh removed their assignment Jan 24, 2022
@Faz95210
Copy link

Faz95210 commented Feb 9, 2022

Hi,

I'm currently experiencing more or less the same issue as the author of the ticket bytedeco/javacv#1696 .
I'm compiling a project in Kotlin through gradle while using your libs

    javacpp_version = '1.5.7-SNAPSHOT'
    ffmpeg_version = "4.4.1-$javacpp_version"

    runtimeOnly "org.bytedeco:ffmpeg:$ffmpeg_version:macosx-x86_64"
    runtimeOnly "org.bytedeco:javacpp:$javacpp_version:macosx-arm64"

I also tried with other mixes of version (4.4-1.5.6/ 4.3.1-1.5.4)

The project used to run perfectly on intel Macs with version 4.3.1-1.5.4
But now, on a Mac M1 whatever the versions used I always get the same error

├─ org.bytedeco.ffmpeg.global.avutil.<clinit>(avutil.java:14)
├─ org.bytedeco.javacpp.Loader.load(Loader.java:1123)
├─ org.bytedeco.javacpp.Loader.load(Loader.java:1300)
├─ org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:1683)
├─ java.lang.System.loadLibrary(System.java:1989)
├─ java.lang.Runtime.loadLibrary0(Runtime.java:818)
├─ java.lang.ClassLoader.loadLibrary(ClassLoader.java:2429)
│
↑ no jniavutil in java.library.path: /Users/faw/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:. (UnsatisfiedLinkError) 
├─ java.lang.ClassLoader.loadLibrary(ClassLoader.java:2429)

I was wondering if you had directions to provide to fix this issue? Specific versions to use or different packages to use?

For reference here is the java version I currently use :

openjdk 17.0.2 2022-01-18
OpenJDK Runtime Environment (build 17.0.2+8-86)
OpenJDK 64-Bit Server VM (build 17.0.2+8-86, mixed mode, sharing)

@saudet
Copy link
Member

saudet commented Feb 9, 2022

The builds are for FFmpeg 5.0, not 4.4.1.

@Faz95210
Copy link

All right, I changed the FFmpeg versions for the project and adapted it from v4 to v5, but then I have a new error :

├─ org.bytedeco.ffmpeg.global.postproc.<clinit>(postproc.java:182)
│  org.bytedeco.ffmpeg.global.postproc.LIBPOSTPROC_VERSION_INT(postproc.java:-2)
│
↑ 'int org.bytedeco.ffmpeg.global.postproc.LIBPOSTPROC_VERSION_INT()' (UnsatisfiedLinkError)

My FFmpeg -version output :

ffmpeg version 5.0 Copyright (c) 2000-2022 the FFmpeg developers
built with Apple clang version 13.0.0 (clang-1300.0.29.30)
configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/5.0 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox --enable-neon
libavutil      57. 17.100 / 57. 17.100
libavcodec     59. 18.100 / 59. 18.100
libavformat    59. 16.100 / 59. 16.100
libavdevice    59.  4.100 / 59.  4.100
libavfilter     8. 24.100 /  8. 24.100
libswscale      6.  4.100 /  6.  4.100
libswresample   4.  3.100 /  4.  3.100
libpostproc    56.  3.100 / 56.  3.100

libpostproc seems to be installed correctly

@saudet
Copy link
Member

saudet commented Feb 10, 2022

I've fixed that in the just released version. Try again with "5.0-1.5.7" (without "-SNAPSHOT"):
https://repo1.maven.org/maven2/org/bytedeco/ffmpeg/5.0-1.5.7/

@Faz95210
Copy link

Thanks ! it seems to work fine now 👍

@saudet
Copy link
Member

saudet commented May 30, 2022

@TheMode It looks like libffi works pretty much out of the box for macosx-arm64, so I've enabled builds for that in commit fff3415. Please give it a try with the snapshots: http://bytedeco.org/builds/

@TheMode
Copy link

TheMode commented May 31, 2022

Thanks!
Currently getting

'int org.bytedeco.libffi.global.ffi.FFI_TYPE_SMALL_STRUCT_1B()'
java.lang.UnsatisfiedLinkError: 'int org.bytedeco.libffi.global.ffi.FFI_TYPE_SMALL_STRUCT_1B()'
	at org.bytedeco.libffi.global.ffi.FFI_TYPE_SMALL_STRUCT_1B(Native Method)
	at org.bytedeco.libffi.global.ffi.<clinit>(ffi.java:109)
	at java.base/java.lang.Class.forName0(Native Method)
	at java.base/java.lang.Class.forName(Class.java:467)
	at org.bytedeco.javacpp.Loader.load(Loader.java:1282)
	at org.bytedeco.javacpp.Loader.load(Loader.java:1227)
	at org.bytedeco.javacpp.Loader.load(Loader.java:1203)
	at org.bytedeco.libffi.ffi_cif.<clinit>(ffi_cif.java:16)

when calling new ffi_cif(); on org.bytedeco:libffi-platform:3.4.2-1.5.8-SNAPSHOT

@saudet
Copy link
Member

saudet commented May 31, 2022

I see, those values are not available on that platform, but they only seem to be used internally, so we probably don't need them. I've fixed that by commenting them out in commit ba57140. Please give it another try! Thanks for testing @TheMode

@TheMode
Copy link

TheMode commented May 31, 2022

Seems to work, thanks!

@lannybroo
Copy link

lannybroo commented Jan 15, 2023

A fresh build of org.bytedeco.ffmpeg-platform via maven worked properly for me with either version 5.0-1.5.7 or 5.1.2-1.5.8 as the ffmpeg-platform version. On macOS Ventura 13.1 on an M1 MacBook Air.

This is in the context of building the jmisb project.

@mkitti
Copy link
Contributor

mkitti commented Mar 10, 2023

What do we need to do build HDF5 for macosx-aarch64?

@OuYubin
Copy link

OuYubin commented Mar 21, 2023

I tried to complete onnx M1 Silicon Support manually, packaged and compiled without problems, and generated the jar files without problems, but when I used it, Throw an exception.

macosx-arm64/libjnionnx.dylib, 0x0001): symbol not found in flat namespace '_onnxGetBackendCompatibility'

the following exception occurred and I was hoping for help. thanks

Exception in thread "main" java.lang.UnsatisfiedLinkError: no jnionnx in java.library.path: /Users/ouyubin/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
	at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2423)
	at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:808)
	at java.base/java.lang.System.loadLibrary(System.java:1893)
	at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:1825)
	at org.bytedeco.javacpp.Loader.load(Loader.java:1416)
	at org.bytedeco.javacpp.Loader.load(Loader.java:1227)
	at org.bytedeco.javacpp.Loader.load(Loader.java:1203)
	at org.bytedeco.onnx.global.onnx.<clinit>(onnx.java:14)
	at java.base/java.lang.Class.forName0(Native Method)
	at java.base/java.lang.Class.forName(Class.java:466)
	at org.bytedeco.javacpp.Loader.load(Loader.java:1282)
	at org.bytedeco.javacpp.Loader.load(Loader.java:1227)
	at org.bytedeco.javacpp.Loader.load(Loader.java:1203)
	at org.bytedeco.onnx.ISchemaRegistry.<clinit>(ISchemaRegistry.java:16)
	at onnx.LoadModel.main(LoadModel.java:9)
Caused by: java.lang.UnsatisfiedLinkError: /Users/ouyubin/.javacpp/cache/onnx-1.12.0-1.5.8-macosx-arm64.jar/org/bytedeco/onnx/macosx-arm64/libjnionnx.dylib: dlopen(/Users/ouyubin/.javacpp/cache/onnx-1.12.0-1.5.8-macosx-arm64.jar/org/bytedeco/onnx/macosx-arm64/libjnionnx.dylib, 0x0001): symbol not found in flat namespace '_onnxGetBackendCompatibility'
	at java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
	at java.base/jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:383)
	at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:227)
	at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:169)
	at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2383)
	at java.base/java.lang.Runtime.load0(Runtime.java:746)
	at java.base/java.lang.System.load(System.java:1857)
	at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:1772)

@saudet
Copy link
Member

saudet commented Mar 21, 2023

We can most likely fix that with a new Info("onnxGetBackendCompatibility").skip():
https://github.com/bytedeco/javacpp/wiki/Mapping-Recipes#skipping-lines-from-header-files

@OuYubin
Copy link

OuYubin commented Mar 21, 2023

We can most likely fix that with a new Info("onnxGetBackendCompatibility").skip(): https://github.com/bytedeco/javacpp/wiki/Mapping-Recipes#skipping-lines-from-header-files

Done,Thanks:)

.put(new Info("onnxGetBackendCompatibility","onnxGetBackendIDs","onnxGetBackendInfo","onnxGetEventState","onnxInitBackend","onnxInitEvent","onnxInitGraph","onnxReleaseBackend","onnxReleaseBackendID","onnxReleaseEvent","onnxReleaseGraph","onnxRunGraph","onnxSetGraphIO","onnxSignalEvent","onnxWaitEvent").skip());

@shouriken
Copy link

mkl still not find jar for macosx-arm64
image

@saudet
Copy link
Member

saudet commented Mar 28, 2023

Intel doesn't provide an ARM version of MKL, that's normal. Please use OpenBLAS instead:
https://github.com/bytedeco/javacpp-presets/tree/master/openblas

@shouriken
Copy link

javacpp haven 1.5.5 version for macosx-arm64, but javacpp-presets‘ sub-modules haven't any for macosx-arm64

@saudet
Copy link
Member

saudet commented Feb 1, 2024

Looks like GitHub Actions now has free M1 runners. That should make it easier to get builds running: https://github.blog/changelog/2024-01-30-github-actions-introducing-the-new-m1-macos-runner-available-to-open-source/

@sbrunk
Copy link
Contributor

sbrunk commented Feb 12, 2024

Looks like GitHub Actions now has free M1 runners. That should make it easier to get builds running: https://github.blog/changelog/2024-01-30-github-actions-introducing-the-new-m1-macos-runner-available-to-open-source/

They need to run on macOS 14 though. If you choose a macos-14 runner, it will automatically run on M1, while macos-11/12/13 runners are provisioned on Intel. Also many paths are different due to homebrew installing under /opt/homebrew instead of /usr/local on ARM. I guess we'll either have to create a new action or put a few conditionals into the existing one.

@saudet
Copy link
Member

saudet commented Feb 12, 2024

Let's not create a new action, let's add branches and what not to deploy-macosx, yes. From what I understand GCC isn't available at all on Apple Silicon, so we can skip all that, and no need to worry about /usr/local paths there.

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