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,

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

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

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

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.

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!

Please support tensorflow-text-macos
 
 
Q