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

Running tasks that require TensorFlow on Apple Silicon #185

Open
lucasgelfond opened this issue May 1, 2023 · 1 comment
Open

Running tasks that require TensorFlow on Apple Silicon #185

lucasgelfond opened this issue May 1, 2023 · 1 comment

Comments

@lucasgelfond
Copy link
Contributor

lucasgelfond commented May 1, 2023

See #184, seems as if we can use Docker Desktop to emulate Intel architecture and don't need to have a platform specific implementation here. Used those changes + a new Docker image, but now getting issues when I try to run 3b, seemingly platform-dependent. When I run 3b, I get:

The TensorFlow library was compiled to use AVX instructions, but these aren't available on your machine.

On further inspection, it looks like AVX is a processor architecture extension that isn't supported on really old machines. Per some of the Apple Developer Documentation it looks like there's some internal framework they use for AVX, but I can't tell if it's supported natively.

A ton of people seem to have similar issues. My working knowledge of processor arch/Docker stuff is pretty limited, but I sense there's two options:

  • use arm64-specific Docker images to run Tensorflow (seems like there is now some official support for this)
  • install an x-platform version of Tensorflow that doesn't require/use AVX. Seems like performance will be worse, but lots of recs to use unofficial tensorflow builds for this (i.e. here.

I tried the second, which looks like it's effectively x-platform (or: compatible with the linux/amd64 Docker container, as far as I understand) but getting this error:

ERROR: tensorflow-2.5.0-cp37-cp37m-linux_x86_64.whl is not a supported wheel on this platform.

Googling this error, I found this thread, which suggests some of the problem might be that the installation expects I'm on Python 3.5, when I'm actually on Python 3.7. Running python3 --version in the developer shell confirms that I'm on Python 3.7.5. However, when I run the suggested pip3 install https://github.com/lhelontra/tensorflow-on-arm/releases/download/v2.4.0/tensorflow-2.4.0-cp37-none-linux_armv7l.whl I get the same error:

ERROR: tensorflow-2.4.0-cp37-none-linux_armv7l.whl is not a supported wheel on this platform.

Any ideas? I think I might still be somewhat lost as to how TF is installed in Docker, and what lies in / outside of pip. Seems like - even if some of the binaries installed are outside of pip and are system-specific, that Rosetta emulation should cover it? (Although evidently not). Any ideas? Open to trying anything, LOL

@breezykermo
Copy link
Member

Thanks- this is a well-referenced error report!

One fix that skirts around the problem rather than solving it-- but one which I would be happy with for the time being-- is to update the tutorial workflow to use the PyTorch pretrained classifiers rather than the tensorflow ones (that is, assuming that they are unproblematic with Apple Silicon). There is nothing in my mind that directly ties the mtriage tutorial to using an analyser that runs Tensorflow on Apple Silicon.This is arguably more of an architecture-specific corner case than a fundamental issue that we should solve in the tutorial workflow.

That said; using an ARM-specific Docker image seems the best solution to the actual problem. As we have discussed, a lot of mtriage has not been updated in several years, and this causes sticking points in the Docker compatibility/runtime in particular, as virtualization support for the latest versions of low-level libraries like Tensorflow is variable across versions. I'd be happy to discuss/pair program solutions to this at the level of the Docker image.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants