Please support tensorflow-text-macos

I know you guys already support tensorflow by two packages: tensorflow-macos and tensorflow-metal. However to work with NLP, users also need tensorflow-text package.

Could you devlopers build a dedicated version tensorflow-text-macos to support this demands.

Best Regards,

Post not yet marked as solved Up vote post of SuperBo Down vote post of SuperBo
7.2k views

Replies

Never mind, I figured out a way to build tensorflow-text from source.

https://github.com/tensorflow/tensorflow/issues/49905

  • Hi SuperBo, Good to know that you were able to make it work by installing build tensorflow-text from source. I was also able to build but when I start my using jupyter notebook, I see error - (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e') If possible, can you please how to build or if you can point to some links

Add a Comment

Here's my experience as of 18 March 2022. Able to install arm64 tensorflow and tensorflow-text and successfully execute the Tensorflow Word Embeddings tutorial found here==> https://www.tensorflow.org/text/guide/word_embeddings. (I downloaded the notebook and ran locally in jupyter)

Create a new virtual environment for this purpose: conda create --name tf_text python=3.8 conda activate tf_text  conda install -c apple tensorflow-deps -y pip install tensorflow-macos  pip install tensorflow-metal  conda install -c conda-forge jupyter jupyterlab -y

Download tensorflow_text-2.8.1-cp38-cp38-macosx_11_0_arm64.whl from here==>https://github.com/sun1638650145/Libraries-and-Extensions-for-TensorFlow-for-Apple-Silicon/releases

pip install /Downloads/tensorflow_text-2.8.1-cp38-cp38-macosx_11_0_arm64.whl

Able to execute the tutorial locally and produce comparable results. HTH

  • It works on m1 max, thanks a lot.

  • Thanks for the link!

  • It doesn't work when I try pip install :(. I am using miniconda3 with tf-text 2.12. Using Mac M1.

Thanks for the info @ConatusEng, but unfortunately I get a ModuleNotFound error when trying to import tensorflow_text. I've tried several different approaches, from various places on the internet, but no luck. I did notice that, for whatever reason, my conda install is miniconda3, not miniforge3, which a lot of people seem to have. I've running torchserve locally under a different env (for several months), and it works fine, so I don't really want to re-install conda if I can help it.

Installing tensorflow-text from source does complete successfully, so I'm really not sure why the module won't load.

Any thoughts?

Yes! I can’t agree more. This library is highly required and despite I was able to build it from the sources too it didn’t work for me :(

I was using 2015 MacBook Pro till September 2022. I am working with NLP project. Our package depending on Tensorflow. And project is using poetry to build. And project's pyproject.toml file was ok. When i moved to new M1 chip MacBook Pro project couldn't be build properly. I'd searched on internet and prepare new one. I've completed build successfully. But when i start training it failed with AttributeError: module 'tensorflow.python.keras.utils.tf_utils' has no attribute 'smart_cond'. And on internet it is said that this is because compatibality problem between tensorflow packages. I installed tensorflow-macos (2.8.0) and tensorflow-metal(0.3.0) tensorflow-addons from "Pip install --upgrade --force --no-dependencies https://github.com/apple/tensorflow_macos/releases/download/v0.1alpha3/tensorflow_addons_macos-0.1a3-cp38-cp38-macosx_11_0_arm64.whl" and tensorflow-text from: " Pip install git+https://github.com/vpol/text.git --no-deps". And now i am not able to work with M1 MacBook pro and still continue to use my windows machine. We need tensorflow libraries work on m1 chip. Tensorflow guys doesn't care about M1 chipset i guess. So we need from you to create addons and text packages for tensorflow. Please help us.

Sigh. Here's a guide to make tensorflow-text work on M1.

I used miniforge to create a virtual environment and installed the latest version of tensorflow-macos (2.10).

To install tensorflow-text for M1, you can find the built wheel for M1 on github. I tried to add a link but the system didn't allow me to post this comment with that link (thanks btw that's really helpful /s)

I could only find a wheel for tensorflow-text v 2.9.

I tried to revert my tensorflow-macos to 2.9, but when I work with it, it throws an error "zsh: bus error". It's not fixable. So I have to stick to tensorflow-macos to 2.10.

Instead, you can build the wheel for tensorflow-text 2.10 from source on your machine. Clone the repository, checkout to tag 2.10, and build. Make sure your conda environment is activated when you do this.

git clone https://github.com/tensorflow/text.git
cd text
git checkout tags/v2.10.0

./oss_scripts/run_build.sh
pip install tensorflow_text-2.10.0-cp39-cp39-macosx_11_0_arm64.whl

The compilation requires bazel version 5.3. For bazel, I recommend using brew install bazelisk -- this has caused me least trouble to set up.

This works for me, but it took way longer than I would have liked.

  • dlopen(/Users/kshitizadhikari/tensorflow-test/env/lib/python3.8/site-packages/tensorflow_text/python/ops/_regex_split_ops.dylib, 0x0006): malformed trie child, cycle to nodeOffset=0x2 weak-def symbol not found (__ZN10tensorflow11register_op19OpDefBuilderWrapper10SetShapeFnENSt3__18functionIFNS_6StatusEPNS_15shape_inference16InferenceContextEEEE)

    throws this error

  • I tried to follow your instructions, but I'm seeing

    external/org_tensorflow/tensorflow/lite/kernels/shim/tflite_op_shim.h:128:35: error: no member named 'OpName' in 'tensorflow::text::ByteSplitterWithOffsetsOp<tflite::shim::Runtime::kTfLite>'

    Have you seen this before?

  • both of these problems look like bugs I get with M1, usually reverting to an older version of tensorflow or setting up a new environment (instead of reverting) helps

Add a Comment

doesn't seem to work in my case .. still unable to install tensorflow-text.. note that I tensorflow 2.12.0 on my M1 mac

  • export CC_OPT_FLAGS=-mavx
  • CC_OPT_FLAGS=-mavx
  • source oss_scripts/configure.sh

+++ uname -s +++ tr A-Z a-z ++ osname=darwin ++ echo darwin darwin ++ '[' -e .bazelrc ']' +++ pip show tensorflow WARNING: Package(s) not found: tensorflow ++ [[ '' == tensorflow ]] +++ pip show tensorflow-macos WARNING: Package(s) not found: tensorflow-macos ++ [[ '' == tensorflow-macos ]] +++ pip show tf-nightly WARNING: Package(s) not found: tf-nightly ++ [[ '' == tf-nightly ]] ++ echo 'Installing tensorflow.' Installing tensorflow. ++ is_macos ++ [[ darwin == \d\a\r\w\i\n ]] +++ arch ++ [[ xarm64 == x\a\r\m\6\4 ]] ++ pip install tensorflow-macos==2.9.0 ERROR: Could not find a version that satisfies the requirement tensorflow-macos==2.9.0 (from versions: 2.13.0rc0) ERROR: No matching distribution found for tensorflow-macos==2.9.0 (nlp) mohamedshiha@Mohameds-MacBook-Pro text % pip install tensorflow_text-2.10.0-cp39-cp39-macosx_11_0_arm64.whl WARNING: Requirement 'tensorflow_text-2.10.0-cp39-cp39-macosx_11_0_arm64.whl' looks like a filename, but the file does not exist ERROR: tensorflow_text-2.10.0-cp39-cp39-macosx_11_0_arm64.whl is not a supported wheel on this platform. (nlp) mohamedshiha@Mohameds-MacBook-Pro text %

Yes please. this is needed to use keras_nlp with tensor flow port for apple silicon (MacBook Pro m2 max)

Hey any news on this?

HuggingFace TFBertTokenizer depends on tensorflow-text

While we can download a custom image locally, testing docker images is a nightmare.

Would be really great to get this fixed thanks!