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 #2504

Merged
merged 4 commits into from
Jul 7, 2021
Merged

Apple silicon support #2504

merged 4 commits into from
Jul 7, 2021

Conversation

tetsuyasu
Copy link
Contributor

@tetsuyasu tetsuyasu commented Jun 16, 2021

Description

Brief Description of the PR: Apple silicon support.

Fixes #2503

Type of change

Checklist:

  • I've properly formatted my code according to the guidelines
    • By running Black + Flake8
    • By running pre-commit hooks
  • This PR addresses an already submitted issue for TensorFlow Addons
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • This PR contains modifications to C++ custom-ops

How Has This Been Tested?

The steps are as follows.

create python virtual environment

(I installed python 3.9.5 with pyenv and pyenv-virtualenv.)

install tensorflow

pip install tensorflow-macos
pip install tensorflow-metal

install bazel 3.7.2

xcode-select --install || echo OK
export BAZEL_VERSION=3.7.2
curl -fLO "https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/bazel-${BAZEL_VERSION}-installer-darwin-x86_64.sh"
chmod +x "bazel-${BAZEL_VERSION}-installer-darwin-x86_64.sh"
./bazel-${BAZEL_VERSION}-installer-darwin-x86_64.sh --user
(set the PATH to bazel)

install tensorflow-addons

export HDF5_DISABLE_VERSION_CHECK=1
git clone https://github.com/tensorflow/addons.git/
cd addons
python3 ./configure.py
bazel build build_pip_pkg
pip install pathlib
bazel-bin/build_pip_pkg artifacts
pip install artifacts/tensorflow_addons-*.whl

@boring-cyborg boring-cyborg bot added the build label Jun 16, 2021
@google-cla google-cla bot added the cla: yes label Jun 16, 2021
@tetsuyasu tetsuyasu marked this pull request as draft June 16, 2021 08:14
@tetsuyasu tetsuyasu marked this pull request as ready for review June 16, 2021 08:19
Copy link
Contributor Author

@tetsuyasu tetsuyasu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't affect builds on other platforms.
Following the way the original code, I left the versions hard-coded.

@bhack bhack requested a review from seanpmorgan June 17, 2021 00:57
@bhack bhack merged commit 9918fe0 into tensorflow:master Jul 7, 2021
@mbui0327
Copy link

I follow your instruction to build from source. But got the following error when running bazel-bin/build_pip_pkg artifacts.
Do you know why?

Traceback (most recent call last):
  File "/private/var/folders/gx/80ykqyq96qq66n6_r20tzywr0000gn/T/tmp.XXXXXXXXXX.BHApfHJa/setup.py", line 81, in <module>
    setup(
  File "/Users/bachbui/miniforge3/envs/py38tf/lib/python3.9/site-packages/setuptools/__init__.py", line 153, in setup
    return distutils.core.setup(**attrs)
  File "/Users/bachbui/miniforge3/envs/py38tf/lib/python3.9/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/Users/bachbui/miniforge3/envs/py38tf/lib/python3.9/distutils/dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "/Users/bachbui/miniforge3/envs/py38tf/lib/python3.9/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/Users/bachbui/miniforge3/envs/py38tf/lib/python3.9/site-packages/wheel/bdist_wheel.py", line 328, in run
    impl_tag, abi_tag, plat_tag = self.get_tag()
  File "/Users/bachbui/miniforge3/envs/py38tf/lib/python3.9/site-packages/wheel/bdist_wheel.py", line 278, in get_tag
    assert tag in supported_tags, "would build wheel with unsupported tag {}".format(tag)
AssertionError: would build wheel with unsupported tag ('cp39', 'cp39', 'macosx_10_13_x86_64')
+ true
+ cp 'dist/*.whl' /Users/bachbui/works/addons/artifacts
cp: dist/*.whl: No such file or directory

@tetsuyasu
Copy link
Contributor Author

Are you using an intel mac?

In your error messages, "macosx_10_13_x86_64" is found.

In the build script (addons/build_deps/build_pip_pkg.sh), m1 mac uses "macosx_11_0_arm64", intel mac uses "macosx_10_13_x86_64".

if [[ x"$(arch)" == x"arm64" ]]; then
  BUILD_CMD="${BUILD_CMD} --plat-name macosx_11_0_arm64"
else
  BUILD_CMD="${BUILD_CMD} --plat-name macosx_10_13_x86_64"
fi

@mbui0327
Copy link

My fault, I ran the term in Rosetta mode and arch return i386. Thanks.

@schr476
Copy link

schr476 commented Sep 18, 2021

I'm having an error with:
build wheel with unsupported tag ('cp39', 'cp39', 'macosx_11_0_arm64')

@bhack
Copy link
Contributor

bhack commented Sep 18, 2021

I'm having an error with:
build wheel with unsupported tag ('cp39', 'cp39', 'macosx_11_0_arm64')

/cc @lgeiger

@lgeiger
Copy link
Contributor

lgeiger commented Sep 18, 2021

@bhack sounds like pip doesn't recognize the MacOS version tag. Can you try updating via python -m pip install pip wheel setuptools --upgrade and try again?

@YashasviMantha
Copy link

YashasviMantha commented Jun 24, 2022

I am getting an error while executing the bazel build build_pip_pkg line.

The error:

no such package '@llvm-raw//utils/bazel': java.io.IOException: Error downloading [https://storage.googleapis.com/mirror.tensorflow.org/github.com/llvm/llvm-project/archive/1cb299165c859533e22f2ed05eb2abd5071544df.tar.gz, https://github.com/llvm/llvm-project/archive/1cb299165c859533e22f2ed05eb2abd5071544df.tar.gz] to /private/var/tmp/_bazel_mantyas/bee8d48923131ee55e0d2124e6da0765/external/llvm-raw/temp16515176952607835268/1cb299165c859533e22f2ed05eb2abd5071544df.tar.gz: Read timed out

I think it has something to do with the hashes. Found a similar issue here: https://github.com/tensorflow/tensorflow/issues/13106

But I am not sure what to change. For context I followed this for installing tensorflow: https://github.com/apple/tensorflow_macos/issues/153

I am on M1 Chip with Miniforge. Would appreciate any help thanks (@tetsuyasu).

The immediate goal is to use hugging face which I think has a dependency on TF.

PS: I tried removing the SHA256 lines from workspaces. Still throws the same error.

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

Successfully merging this pull request may close these issues.

tensorflow-addons doesn't work with tensorflow-macos
6 participants