sun1638650145 / Libraries-and-Extensions-for-TensorFlow-for-Apple-Silicon

This Repo will provide TensorFlow libraries and extended build tutorials that require compilation to build, as well as pre-compiled wheel files.
115 stars 9 forks source link

tensorflow-text build issues #1

Closed anpaulin closed 2 years ago

anpaulin commented 2 years ago

First off, I applaud you for maintaining these instructions for people struggling with getting things running on an M1 machine...

Following you instructions for building tensorflow_text, I run into the following issue:

ERROR: /private/var/tmp/_bazel_USER/9f8724fe94ef5d3d184dee8c41f63e97/external/com_google_protobuf/BUILD:981:21: in proto_lang_toolchain rule @com_google_protobuf//:cc_toolchain: '@com_google_protobuf//:cc_toolchain' does not have mandatory provider 'ProtoInfo'.

I tried various suggestions on modifying the WORKPLACE file, but haven't been able to get around it....

sun1638650145 commented 2 years ago

Although I want to share you how to build in as much detail as possible, there are still various problems. There are three main aspects:

  1. If it's just for use, I provide a pre compiled wheel.
  2. Most of the problems in the build process are caused by bazel. You can carefully check your bazel. If you have installed it with brew on a mac, it is likely that the uninstallation is not clean. Please check whether the soft link is correct to the specified version.
  3. Please provide your system and environment information, I can't find the cause of the error with only one error.
anpaulin commented 2 years ago

I would love to use your precompiled wheel, however unfortunately I'm working with a project that only supports Java 8 at the moment and going to be using the JAVA api for tensorfow. As such, your precompiled wheel is for tensorflow-text version 2.8.1, which requires tensorflow version 2.8. Unfortunately, the only version of the tensorflow java project that is compatible with 2.8+ is 0.5.0 which only supports Java 11+...

As you can see I'm in a bit of a predicament here...

If you could supply a wheel for 2.7 of tensorflow-text I would be forever grateful. In the meantime, I'll loop back around and get provide more details regarding my initial question & error message

anpaulin commented 2 years ago

Looping back around I checked out branch 2.7 which looks to have your commit which adds M1 support as its latest commit.

running ./oss_scripts/run_build.sh I get the following error:

ERROR: /private/var/tmp/_bazel_USER/f34013cb46e7b7980816551b07367b89/external/bazel_tools/src/tools/launcher/BUILD:9:14: While resolving toolchains for target @bazel_tools//src/tools/launcher:launcher: No matching toolchains found for types @bazel_tools//tools/cpp:toolchain_type. Maybe --incompatible_use_cc_configure_from_rules_cc has been flipped and there is no default C++ toolchain added in the WORKSPACE file? See https://github.com/bazelbuild/bazel/issues/10134 for details and migration instructions.
ERROR: Analysis of target '//oss_scripts/pip_package:build_pip_package' failed; build aborted: 

MacOS == 12.3.1 Machine == 2020 MacbookPro tensorflow-macos == 2.7.0 bazel == 5.1.1

sun1638650145 commented 2 years ago

This tutorial currently only works with tensorflow-text 2.8.x, so it is possible that your build will fail. Based on the information you provided, your bazel version is too high, tensorflow-text 2.7 must use bazel 3.7.2, any other version will fail. So you need to downgrade your bazel.

anpaulin commented 2 years ago

That's strange... when I ran the /oss_scripts/run_build.sh with bazel 4.2.2 on the latest commit of 2.7 I get the following error:

ERROR: The project you're trying to build requires Bazel 5.1.1
sun1638650145 commented 2 years ago

That's because the source code of tensorflow is downloaded when building tensorflow-text, and the master branch currently uses bazel 5.1.1.

sun1638650145 commented 2 years ago

In this case you may need to modify the build script to switch the downloaded tensorflow branch to 2.7.

anpaulin commented 2 years ago

I do believe the tensorflow version is set correctly

Starting local Bazel server and connecting to it...
Loading: 0 packages loaded
    Fetching @org_tensorflow; fetching 27s
    Fetching https://github.com/tensorflow/tensorflow/archive/v2.7.0.zip; 39,428,608B 26s

I encourage you to checkout 2.7 of tensorflow-text and try running the build script.

sun1638650145 commented 2 years ago

I'm sorry that my previous build of tensorflow-text 2.7 can't be found, since the precompiled package for M1 is only available from bazel 4.0.0. Recompiling basel 3.7.2 will break a lot of current things (you should also know that there is no docker image for macOS).

sun1638650145 commented 2 years ago

I found a wheel from a previous PR, hope it helps you.

anpaulin commented 2 years ago

Sadly it seems that wheel isn't the one I need...

Do you have tensorflow_text-2.7.0-cp39-cp39-macosx_11_0_arm64.whl ?