-
Notifications
You must be signed in to change notification settings - Fork 214
Does TensorFlow-Java support Apple Silicon Macs? #252
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
Comments
Neither TF-Java nor upstream Tensorflow are supported on M1 Macs. Apple made a Python only version of TF available (https://github.com/apple/tensorflow_macos), and are upstreaming that support into mainline Tensorflow. When that all lands you'll be able to run it, and possibly TF-Java, though you'll still have to compile it from source as we won't make M1 Mac builds available due to a lack of build resources. From your crash report it looks like you're running the JVM through Apple's Rosetta translation layer. That layer does not support AVX instructions, which are used by TF to provide accelerated math operations, and attempting to use such an instruction causes the process to terminate with a SIGILL. This will happen for pretty much every build of TF-Java, and of upstream Python TF. I'm not sure why 1.13.1 doesn't trigger the issue, it might just be the way things are loaded in that version so it doesn't hit an AVX instruction, however it will hit one whenever you try to do anything useful like multiply a matrix or use a convolution. You might have more luck if you download a macOS aarch64 JVM, and then try to build TF-Java from source. Note you'll need to already have installed Apple's tf_macos as that pulls in a hacked up version of numpy with M1 support and Tensorflow needs numpy to build. The last time I tried this on my M1 Mac, it still failed, but that was before we upgraded to TF 2.4.1 so you might have better luck now. |
With tensorflow-java soon supporting TF2.5 and Apple announcing tensorflow-metal a TF2.5 PluggableDevice: |
I was considering trying However we still can't make a macOS arm64 build as all our builds are done in Github Actions, and they don't have runners for that platform yet. |
Thanks for the feedback. |
Well, if everything works it should be as straightforward as just checking out the head of the TF-Java repo, getting the right version of bazel installed (making sure that version is native not running on Rosetta), and then running |
I spent a few hours poking at it. It doesn't build, even after porting across a bunch of bazel changes from upstream TF, and then hacking on various bits of the bazel build. I keep hitting some issue with compiling protobuf which I haven't figured out yet. I think we might need help from TF SIG-Build. |
Would TF-Java for the M1 macs likely be supported? If so, would someone be kind enough to share the milestones if it exists? |
Are there any updates on building tf-java for M1? I'm willing to upgrade my M1 to macOS 12 to test it out. |
It turns out that with the latest macOS betas, you can install them on separate partition from your main partition. |
Is there any update for this thread? |
@zhenglaizhang , current status is the same, since GitHub actions still do not host Apple Silicon machines required for building TF binaries that are specific to TFJava. A new issue (#475) duplicating this one has just started, you might also want to take a look at it. |
Hi there, is there any update on using Tensorflow-Java on an M1? Tensorflow with Python is working fine for me and I have installed Tensorflow-metal, but I would need to use Tensorflow in Java as well. |
I think it should compile from source, but we're still unable to provide binaries. We're looking to move towards using Google's binaries for the C API, which will make that simpler, but the work isn't complete and we might still hit some roadblocks. |
Okay, thanks for the update. |
Hey folks! Just wanted to share the GitHub actions recently announced a public beta for Apple Silicon runners (see: blog). Does that mean that building distributable TF binaries for aarch64 is as simple as updating the |
Those runners aren't free, so I don't think we can use them. However we've made good progress on using prebuilt binaries so the next release should have support for macOS arm64 once we've landed all the build system changes. |
I am also facing this issue and looking forward for binaries, please update once its available Thanks. |
Binaries are available in the 1.0.0-rc1 release. |
Sorry to comment on a closed issue but still seeing this error on the 1.0.0-rc1 release: Thank you!
Could this be because I am using a non native JVM build? |
Yeah, SIGILL means it tried to execute an illegal instruction (i.e., one which is invalid for the CPU it's executing on). If you want to run the JVM under Rosetta then you should pull in the macOS x86_64 build of TF-Java, though you should note this is likely to be a bad idea as Rosetta doesn't support any SIMD operations so it'll either run really slowly, or crash with another SIGILL. |
Please make sure that this is a bug. As per our GitHub Policy, we only address code/doc bugs, performance issues, feature requests and build/installation issues on GitHub. tag:bug_template
System information
Describe the current behavior
I just try to run tensorflow java offical example, and get tensorflow version for test. but It dosen't work.
I have test different versions of tensorflow java interface, and only ver 1.13.1 works well.
And all other versions can not work, for example old tensorflow version(1.4.0/1.5.0), and new tensorflow Java Version 0.2.0/0.3.0(tensorflow ver2.3.1/2.4.1) .
The Error shows below:
Code to reproduce the issue
Java code:
pom.xml
The text was updated successfully, but these errors were encountered: