Skip to content

Latest commit

 

History

History
55 lines (38 loc) · 1.78 KB

File metadata and controls

55 lines (38 loc) · 1.78 KB

Build TensorFlow Text from source

Prerequisites

It is assumed here that you have the necessary Unix-Like knowledge, brew and conda have been installed in your terminal, and the installation and use methods of brew and conda will not be repeated here; most importantly, this tutorial is completely based on Apple silicon build, so make sure your Mac is Apple silicon.

Step by Step

  1. Create a new Env and install the dependencies provided by Apple.

    conda create -n tensorflow-macos python=3.12 # Python 3.9, 3.10 and 3.11 are also supported.
    conda activate tensorflow-macos
    
  2. Install the tensorflow.

    pip install tensorflow==2.18.0
    
  3. Install bazel 6.5.0.

    wget https://github.com/bazelbuild/bazel/releases/download/6.5.0/bazel-6.5.0-darwin-arm64 -O bazel
    chmod +x bazel
    sudo mv bazel /usr/local/bin/
    bazel --version # Make sure the version is 6.5.0.
    
  4. Download and extract text 2.18.1.

    wget https://github.com/tensorflow/text/archive/refs/tags/v2.18.1.zip
    unzip ./v2.18.1.zip
    cd text-2.18.1
    
  5. Run the script.

    ./oss_scripts/run_build.sh
    
  6. Please do not forget to install the whl file.

    pip install ./*.whl
    

Tips&Refer

  1. Text needs to correspond to a minor version of tensorflow (e.g. tensorflow-macos==2.7.0 and tensorflow-text==2.7.3)
  2. Please ensure that your network is stable during the compilation process, and the compilation needs to use the network.
  3. I add a PR for Apple Silicon support.