├── .gitignore ├── README-zh.md ├── README.md └── tutorials ├── addons ├── addons-zh.md └── addons.md ├── io ├── io-zh.md └── io.md ├── tensorflow ├── tensorflow-zh.md └── tensorflow.md └── text ├── text-zh.md └── text.md /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .idea/ -------------------------------------------------------------------------------- /README-zh.md: -------------------------------------------------------------------------------- 1 | # 用于 Apple 芯片的 TensorFlow 库和扩展 2 | 3 | 这个仓库将提供需要编译才能构建的 TensorFlow 库和拓展的构建教程, 同时也提供预编译的`wheel`文件. 本教程提供[简体中文](https://github.com/sun1638650145/Libraries-and-Extensions-for-TensorFlow-for-Apple-Silicon/blob/main/README-zh.md)和[English](https://github.com/sun1638650145/Libraries-and-Extensions-for-TensorFlow-for-Apple-Silicon/blob/main/README.md)支持. 4 | 5 | ## 目前提供的教程 👉 6 | 7 | * [addons](https://github.com/tensorflow/addons) 8 | * [io](https://github.com/tensorflow/io) 9 | * [text](https://github.com/tensorflow/text) 10 | * 未完待续 11 | 12 | ## 注意 ⚠️ 13 | 14 | * 从`tensorflow-macos 2.9.0`和`tensorflow-metal 0.5.0`才开始提供了`Python 3.10`的支持. 15 | * 从`tensorflow 2.13.0`开始官方提供Apple 芯片的支持和`Python 3.11`的支持. 16 | * 从`tensorflow 2.14.0`开始移除了`Python 3.8`的支持. 17 | * 从`tensorflow 2.16.1`开始提供`Python 3.12`的支持. 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Libraries and Extensions for TensorFlow for Apple Silicon 2 | 3 | This Repo will provide TensorFlow libraries and extended build tutorials that require compilation to build, as well as pre-compiled `wheel` files. This tutorial provides [English](https://github.com/sun1638650145/Libraries-and-Extensions-for-TensorFlow-for-Apple-Silicon/blob/main/README.md) and [简体中文](https://github.com/sun1638650145/Libraries-and-Extensions-for-TensorFlow-for-Apple-Silicon/blob/main/README-zh.md) support. 4 | 5 | ## Currently available tutorials 👉🏻 6 | 7 | * [addons](https://github.com/tensorflow/addons) 8 | * [io](https://github.com/tensorflow/io) 9 | * [text](https://github.com/tensorflow/text) 10 | * To be continued... 11 | 12 | ## Note ⚠️ 13 | 14 | * `Python 3.10` support has been provided since `tensorflow-macos 2.9.0` and `tensorflow-metal 0.5.0`. 15 | * Official support for `Apple silicon` and `Python 3.11` was introduced starting from `tensorflow 2.13.0`. 16 | * Starting from `tensorflow 2.14.0`, support for `Python 3.8` has been removed. 17 | * Support for `Python 3.12` is provided starting from `tensorflow 2.16.1`. 18 | -------------------------------------------------------------------------------- /tutorials/addons/addons-zh.md: -------------------------------------------------------------------------------- 1 | # 从源码构建TensorFlow Addons 2 | 3 | ## 注意 ⚠️ 4 | 5 | `TensorFlow Addons`已经停止服务, 当前是保留的旧版本构建教程! 6 | 7 | ## 必要条件 8 | 9 | 这里假设了您有必要的类Unix知识, 已经在您的终端内安装好了[`brew`](https://brew.sh)和[`conda`](https://github.com/conda-forge/miniforge), 这里不再赘述`brew`和`conda`安装和使用方法; 最重要的是, 这个教程完全基于Apple 芯片构建, 所以确保您手中的Mac是Apple 芯片. 10 | 11 | ## Step by Step 12 | 13 | 1. 创建新的环境并安装Apple提供的依赖项. 14 | 15 | ```shell 16 | conda create -n tensorflow-macos python=3.11 # 这里Python版本也可以使用Python 3.9或3.10. 17 | conda activate tensorflow-macos 18 | ``` 19 | 20 | 2. 安装`tensorflow`和`tensorflow-metal`插件. 21 | 22 | ```shell 23 | pip install tensorflow==2.15.0 24 | pip install tensorflow-metal==1.1.0 25 | ``` 26 | 27 | 3. 安装`bazel 6.1.0`. 28 | 29 | ```shell 30 | wget https://raw.githubusercontent.com/Homebrew/homebrew-core/a9b3083e23806aebe61f7c39d393734a6949eaa5/Formula/bazel.rb 31 | brew install ./bazel.rb 32 | bazel --version # 确保版本是6.1.0即可. 33 | ``` 34 | 35 | * 通常情况下`brew`安装的`bazel`会是最新版的, 最新版往往和`addons`要求的版本不匹配, 这可能会出现很多意想不到的问题, 所以我们通过手动指定版本安装. 36 | 37 | 4. 下载并解压`addons 0.23.0`. 38 | 39 | ```shell 40 | wget https://github.com/tensorflow/addons/archive/refs/tags/v0.23.0.zip 41 | unzip ./v0.23.0.zip 42 | cd addons-0.23.0 43 | ``` 44 | 45 | 5. 运行脚本构建. 46 | 47 | ```shell 48 | python3 ./configure.py 49 | bazel build build_pip_pkg 50 | bazel-bin/build_pip_pkg artifacts 51 | ``` 52 | 53 | 6. 千万不要忘记安装`whl`文件. 54 | 55 | ```shell 56 | pip install artifacts/*.whl 57 | ``` 58 | 59 | ## Tips&Refer 60 | 61 | 1. `addons`需要和`tensorflow`的版本对应. 具体对应关系在[这里](https://github.com/tensorflow/addons/blob/a5cd76d341c594f464a5c9be8e572ed5bd3f3b8b/README.md?plain=1#L80). 62 | 2. 编译过程中请保证你的网络稳定, 编译需要使用网络. 63 | 3. [本人添加Apple 芯片Python 3.10支持PR.](https://github.com/tensorflow/addons/pull/2718) 64 | 65 | -------------------------------------------------------------------------------- /tutorials/addons/addons.md: -------------------------------------------------------------------------------- 1 | # Build TensorFlow Addons from source 2 | 3 | ## Note ⚠️ 4 | 5 | `TensorFlow Addons` has ended development, and this tutorial is for building legacy versions only! 6 | 7 | ## Prerequisites 8 | 9 | It is assumed here that you have the necessary Unix-Like knowledge, [`brew`](https://brew.sh) and [`conda`](https://github.com/conda-forge/miniforge) 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. 10 | 11 | ## Step by Step 12 | 13 | 1. Create a new Env and install the dependencies provided by Apple. 14 | 15 | ```shell 16 | conda create -n tensorflow-macos python=3.11 # Python 3.9 and 3.10 are also supported. 17 | conda activate tensorflow-macos 18 | ```` 19 | 20 | 2. Install the `tensorflow` and `tensorflow-metal` plugins. 21 | 22 | ```shell 23 | pip install tensorflow==2.15.0 24 | pip install tensorflow-metal==1.1.0 25 | ```` 26 | 27 | 3. Install `bazel 6.1.0`. 28 | 29 | ```shell 30 | wget https://raw.githubusercontent.com/Homebrew/homebrew-core/a9b3083e23806aebe61f7c39d393734a6949eaa5/Formula/bazel.rb 31 | brew install ./bazel.rb 32 | bazel --version # Make sure the version is 6.1.0. 33 | ```` 34 | 35 | * Normally, the version of `bazel` installed via `brew` is the latest one, which may not match the version required by the `addons`. This can lead to unexpected issues, so we need to manually specify the version for installation. 36 | 37 | 4. Download and extract `addons 0.23.0`. 38 | 39 | ```shell 40 | wget https://github.com/tensorflow/addons/archive/refs/tags/v0.23.0.zip 41 | unzip ./v0.23.0.zip 42 | cd addons-0.23.0 43 | ```` 44 | 45 | 5. Run the script. 46 | 47 | ```shell 48 | python3 ./configure.py 49 | bazel build build_pip_pkg 50 | bazel-bin/build_pip_pkg artifacts 51 | ```` 52 | 53 | 6. Please do not forget to install the `whl` file. 54 | 55 | ```shell 56 | pip install artifacts/*.whl 57 | ``` 58 | 59 | ## Tips&Refer 60 | 61 | 1. `Addons` need to correspond with the version of `tensorflow`. The specific correspondence is [here](https://github.com/tensorflow/addons/blob/a5cd76d341c594f464a5c9be8e572ed5bd3f3b8b/README.md?plain=1#L80). 62 | 2. Please ensure that your network is stable during the compilation process, and the compilation needs to use the network. 63 | 3. [I add Python 3.10 support for r0.17 of Apple Silicon.](https://github.com/tensorflow/addons/pull/2718) 64 | -------------------------------------------------------------------------------- /tutorials/io/io-zh.md: -------------------------------------------------------------------------------- 1 | # 从源码构建TensorFlow I/O 2 | 3 | ## 必要条件 4 | 5 | 这里假设了您有必要的类Unix知识, 已经在您的终端内安装好了[`brew`](https://brew.sh)和[`conda`](https://github.com/conda-forge/miniforge), 这里不再赘述`brew`和`conda`安装和使用方法; 最重要的是, 这个教程完全基于Apple 芯片构建, 所以确保您手中的Mac是Apple 芯片. 6 | 7 | ## Step by Step 8 | 9 | 1. 创建新的环境并安装Apple提供的依赖项. 10 | 11 | ```shell 12 | conda create -n tensorflow-macos python=3.11 # 这里Python版本也可以使用Python 3.9或3.10. 13 | conda activate tensorflow-macos 14 | ``` 15 | 16 | 2. 安装`tensorflow`和`tensorflow-metal`插件. 17 | 18 | ```shell 19 | pip install tensorflow==2.15.0 20 | pip install tensorflow-metal==1.1.0 21 | ``` 22 | 23 | 3. 安装`bazel 6.1.0`. 24 | 25 | ```shell 26 | wget https://raw.githubusercontent.com/Homebrew/homebrew-core/a9b3083e23806aebe61f7c39d393734a6949eaa5/Formula/bazel.rb 27 | brew install ./bazel.rb 28 | bazel --version # 确保版本是6.1.0即可. 29 | ``` 30 | 31 | * 通常情况下`brew`安装的`bazel`会是最新版的, 最新版往往和`io`要求的版本不匹配, 这可能会出现很多意想不到的问题, 所以我们通过手动指定版本安装. 32 | 33 | 4. 下载并解压`io 0.36.0`. 34 | 35 | ```shell 36 | wget https://github.com/tensorflow/io/archive/refs/tags/v0.36.0.zip 37 | unzip ./v0.36.0.zip 38 | cd io-0.36.0 39 | ``` 40 | 41 | 5. 设置环境变量`TF_PYTHON_VERSION`. 42 | 43 | ```shell 44 | export TF_PYTHON_VERSION=3.11 # 这里Python版本也可以使用Python 3.9或3.10. 45 | ``` 46 | 47 | 6. 运行脚本构建. 48 | 49 | ```shell 50 | python tools/build/configure.py 51 | bazel build \ 52 | ${BAZEL_OPTIMIZATION} \ 53 | -- //tensorflow_io_gcs_filesystem/... //tensorflow_io:python/ops/libtensorflow_io.so //tensorflow_io:python/ops/libtensorflow_io_plugins.so 54 | ``` 55 | 56 | 7. 生成`tensorflow-io`和`tensorflow-io-gcs-filesystem`的`whl`文件. 57 | 58 | ```shell 59 | python setup.py --data bazel-bin -q bdist_wheel --plat-name macosx_12_0_arm64 60 | rm -rf build 61 | python setup.py --project tensorflow-io-gcs-filesystem --data bazel-bin -q bdist_wheel --plat-name macosx_12_0_arm64 62 | ``` 63 | 64 | 8. 千万不要忘记安装`whl`文件, 需要先安装`tensorflow-io-gcs-filesystem`然后再安装`tensorflow-io`. 65 | 66 | ```shell 67 | pip install dist/tensorflow_io_gcs_filesystem-*.whl 68 | pip install dist/tensorflow_io-*.whl 69 | ``` 70 | 71 | ## Tips&Refer 72 | 73 | 1. `io`需要和`tensorflow`的版本对应. 具体对应关系在[这里](https://github.com/tensorflow/io/blob/master/README.md#tensorflow-version-compatibility). 74 | 2. 编译过程中请保证你的网络稳定, 编译需要使用网络. 75 | -------------------------------------------------------------------------------- /tutorials/io/io.md: -------------------------------------------------------------------------------- 1 | # Build TensorFlow I/O from source 2 | 3 | ## Prerequisites 4 | 5 | It is assumed here that you have the necessary Unix-Like knowledge, [`brew`](https://brew.sh) and [`conda`](https://github.com/conda-forge/miniforge) 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. 6 | 7 | ## Step by Step 8 | 9 | 1. Create a new Env and install the dependencies provided by Apple. 10 | 11 | ```shell 12 | conda create -n tensorflow-macos python=3.11 # Python 3.9 and 3.10 are also supported. 13 | conda activate tensorflow-macos 14 | ```` 15 | 16 | 2. Install the `tensorflow` and `tensorflow-metal` plugins. 17 | 18 | ```shell 19 | pip install tensorflow==2.15.0 20 | pip install tensorflow-metal==1.1.0 21 | ```` 22 | 23 | 3. Install `bazel 6.1.0`. 24 | 25 | ```shell 26 | wget https://raw.githubusercontent.com/Homebrew/homebrew-core/a9b3083e23806aebe61f7c39d393734a6949eaa5/Formula/bazel.rb 27 | brew install ./bazel.rb 28 | bazel --version # Make sure the version is 6.1.0. 29 | ```` 30 | 31 | * Normally, the version of `bazel` installed via `brew` is the latest one, which may not match the version required by the `io`. This can lead to unexpected issues, so we need to manually specify the version for installation. 32 | 33 | 4. Download and extract `io 0.36.0`. 34 | 35 | ```shell 36 | wget https://github.com/tensorflow/io/archive/refs/tags/v0.36.0.zip 37 | unzip ./v0.36.0.zip 38 | cd io-0.36.0 39 | ```` 40 | 41 | 5. Set the environment variable `TF_PYTHON_VERSION`. 42 | 43 | ```shell 44 | export TF_PYTHON_VERSION=3.11 # Python 3.9 and 3.10 are also supported. 45 | ``` 46 | 47 | 6. Run the script. 48 | 49 | ```shell 50 | python tools/build/configure.py 51 | bazel build \ 52 | ${BAZEL_OPTIMIZATION} \ 53 | -- //tensorflow_io_gcs_filesystem/... //tensorflow_io:python/ops/libtensorflow_io.so //tensorflow_io:python/ops/libtensorflow_io_plugins.so 54 | ```` 55 | 56 | 7. Generate `whl` files for `tensorflow-io` and `tensorflow-io-gcs-filesystem`. 57 | 58 | ```shell 59 | python setup.py --data bazel-bin -q bdist_wheel --plat-name macosx_12_0_arm64 60 | rm -rf build 61 | python setup.py --project tensorflow-io-gcs-filesystem --data bazel-bin -q bdist_wheel --plat-name macosx_12_0_arm64 62 | ``` 63 | 64 | 8. Please do not forget to install the `whl` file, and you need to install `tensorflow-io-gcs-filesystem` first and then install `tensorflow-io`. 65 | 66 | ```shell 67 | pip install dist/tensorflow_io_gcs_filesystem-*.whl 68 | pip install dist/tensorflow_io-*.whl 69 | ``` 70 | 71 | ## Tips&Refer 72 | 73 | 1. `io` need to correspond with the version of `tensorflow`. The specific correspondence is [here](https://github.com/tensorflow/io/blob/master/README.md#tensorflow-version-compatibility). 74 | 2. Please ensure that your network is stable during the compilation process, and the compilation needs to use the network. 75 | -------------------------------------------------------------------------------- /tutorials/tensorflow/tensorflow-zh.md: -------------------------------------------------------------------------------- 1 | # 从源码构建 TensorFlow 2 | 3 | ## 必要条件 4 | 5 | 请使用`Xcode 15.3`和`Apple clang version 15.0.0 (clang-1500.3.9.4)`及以上版本, 之前的版本可以确认`ld`命令存在问题. 同时假设您有丰富的编译开发经验, 关于工具链和环境的其他部分就不再赘述. 6 | 7 | ## Step by Step 8 | 9 | 1. 创建新的环境. 10 | 11 | ```shell 12 | conda create -n tensorflow-macos python=3.12 # 这里Python版本也可以使用Python 3.9, 3.10和3.11. 13 | conda activate tensorflow-macos 14 | ``` 15 | 16 | 2. 安装`bazel 6.5.0`. 17 | 18 | ```shell 19 | wget https://github.com/bazelbuild/bazel/releases/download/6.5.0/bazel-6.5.0-darwin-arm64 -O bazel 20 | chmod +x bazel 21 | sudo mv bazel /usr/local/bin/ 22 | bazel --version # 确保版本是6.5.0即可. 23 | ``` 24 | 25 | 3. 下载并解压`tensorflow 2.19.0`. 26 | 27 | ```shell 28 | wget https://github.com/tensorflow/tensorflow/archive/refs/tags/v2.19.0.zip 29 | unzip v2.19.0.zip 30 | cd tensorflow-2.19.0 31 | ``` 32 | 33 | 4. 设置环境变量`TF_PYTHON_VERSION`. 34 | 35 | ```shell 36 | export TF_PYTHON_VERSION=3.12 # 请和上面的Python版本对应. 37 | ``` 38 | 39 | 5. 配置build. 40 | 41 | ```shell 42 | ./configure # 请全部使用默认选项. 43 | ``` 44 | 45 | 6. 构建`tensorflow`(在作者本人的`M1 MacBook Pro 16GB`大概需要`70`分钟). 46 | 47 | ```shell 48 | bazel build //tensorflow/tools/pip_package:wheel 49 | ``` 50 | 51 | 7. 安装`whl`文件. 52 | 53 | ```shell 54 | pip install ./bazel-bin/tensorflow/tools/pip_package/wheel_house/*.whl 55 | ``` 56 | 57 | ## Tips 58 | 59 | 1. 编译过程中请保证你的网络稳定, 编译需要使用网络. 60 | -------------------------------------------------------------------------------- /tutorials/tensorflow/tensorflow.md: -------------------------------------------------------------------------------- 1 | # Build TensorFlow from source 2 | 3 | ## Prerequisites 4 | 5 | Please use `Xcode 15.3` and `Apple clang version 15.0.0 (clang-1500.3.9.4)` or later versions is required. Previous versions may encounter issues with the `ld` command. It is also assumed that you have extensive experience in compilation and development and are familiar with other aspects of toolchains and environments. Further details will not be discussed here. 6 | 7 | ## Step by Step 8 | 9 | 1. Create a new Env. 10 | 11 | ```shell 12 | conda create -n tensorflow-macos python=3.12 # Python 3.9, 3.10 and 3.11 are also supported. 13 | conda activate tensorflow-macos 14 | ``` 15 | 16 | 2. Install `bazel 6.5.0`. 17 | 18 | ```shell 19 | wget https://github.com/bazelbuild/bazel/releases/download/6.5.0/bazel-6.5.0-darwin-arm64 -O bazel 20 | chmod +x bazel 21 | sudo mv bazel /usr/local/bin/ 22 | bazel --version # Make sure the version is 6.5.0. 23 | ``` 24 | 25 | 3. Download and extract `tensorflow 2.19.0`. 26 | 27 | ```shell 28 | wget https://github.com/tensorflow/tensorflow/archive/refs/tags/v2.19.0.zip 29 | unzip v2.19.0.zip 30 | cd tensorflow-2.19.0 31 | ``` 32 | 33 | 4. Set the environment variable `TF_PYTHON_VERSION`. 34 | 35 | ```shell 36 | export TF_PYTHON_VERSION=3.12 # Corresponding to the Python version above, please. 37 | ``` 38 | 39 | 5. Configure the build. 40 | 41 | ```shell 42 | ./configure # Please use all default options. 43 | ``` 44 | 45 | 6. Build `tensorflow` (which takes approximately `70` minutes on the author's M1 MacBook Pro `16`GB). 46 | 47 | ```shell 48 | bazel build //tensorflow/tools/pip_package:wheel 49 | ``` 50 | 51 | 7. Install the `whl` file. 52 | 53 | ```shell 54 | pip install ./bazel-bin/tensorflow/tools/pip_package/wheel_house/*.whl 55 | ``` 56 | 57 | ## Tips 58 | 59 | 1. Please ensure that your network is stable during the compilation process, and the compilation needs to use the network. 60 | -------------------------------------------------------------------------------- /tutorials/text/text-zh.md: -------------------------------------------------------------------------------- 1 | # 从源码构建TensorFlow Text 2 | 3 | ## 必要条件 4 | 5 | 这里假设了您有必要的类Unix知识, 已经在您的终端内安装好了[`brew`](https://brew.sh)和[`conda`](https://github.com/conda-forge/miniforge), 这里不再赘述`brew`和`conda`安装和使用方法; 最重要的是, 这个教程完全基于Apple 芯片构建, 所以确保您手中的Mac是Apple 芯片. 6 | 7 | ## Step by Step 8 | 9 | 1. 创建新的环境并安装Apple提供的依赖项. 10 | 11 | ```shell 12 | conda create -n tensorflow-macos python=3.12 # 这里Python版本也可以使用Python 3.9, 3.10和3.11. 13 | conda activate tensorflow-macos 14 | ``` 15 | 16 | 2. 安装`tensorflow`. 17 | 18 | ```shell 19 | pip install tensorflow==2.19.0 20 | ``` 21 | 22 | 3. 安装`bazel 6.5.0`. 23 | 24 | ```shell 25 | wget https://github.com/bazelbuild/bazel/releases/download/6.5.0/bazel-6.5.0-darwin-arm64 -O bazel 26 | chmod +x bazel 27 | sudo mv bazel /usr/local/bin/ 28 | bazel --version # 确保版本是6.5.0即可. 29 | ``` 30 | 31 | 4. 下载并解压`text 2.19.0`. 32 | 33 | ```shell 34 | wget https://github.com/tensorflow/text/archive/refs/tags/v2.19.0.zip 35 | unzip ./v2.19.0.zip 36 | cd text-2.19.0 37 | ``` 38 | 39 | 5. 运行脚本构建. 40 | 41 | ```shell 42 | ./oss_scripts/run_build.sh 43 | ``` 44 | 45 | 6. [千万不要忘记安装whl文件.](https://github.com/sun1638650145/Libraries-and-Extensions-for-TensorFlow-for-Apple-Silicon/issues/2) 46 | 47 | ```shell 48 | pip install ./*.whl 49 | ``` 50 | 51 | ## Tips&Refer 52 | 53 | 1. `text`需要和`tensorflow`的次要版本对应(比如`tensorflow-macos==2.7.0`和`tensorflow-text==2.7.3`) 54 | 2. 编译过程中请保证你的网络稳定, 编译需要使用网络. 55 | 3. [本人添加Apple Silicon支持的PR.](https://github.com/tensorflow/text/pull/756) 56 | -------------------------------------------------------------------------------- /tutorials/text/text.md: -------------------------------------------------------------------------------- 1 | # Build TensorFlow Text from source 2 | 3 | ## Prerequisites 4 | 5 | It is assumed here that you have the necessary Unix-Like knowledge, [`brew`](https://brew.sh) and [`conda`](https://github.com/conda-forge/miniforge) 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. 6 | 7 | ## Step by Step 8 | 9 | 1. Create a new Env and install the dependencies provided by Apple. 10 | 11 | ```shell 12 | conda create -n tensorflow-macos python=3.12 # Python 3.9, 3.10 and 3.11 are also supported. 13 | conda activate tensorflow-macos 14 | ```` 15 | 16 | 2. Install the `tensorflow`. 17 | 18 | ```shell 19 | pip install tensorflow==2.19.0 20 | ```` 21 | 22 | 3. Install `bazel 6.5.0`. 23 | 24 | ```shell 25 | wget https://github.com/bazelbuild/bazel/releases/download/6.5.0/bazel-6.5.0-darwin-arm64 -O bazel 26 | chmod +x bazel 27 | sudo mv bazel /usr/local/bin/ 28 | bazel --version # Make sure the version is 6.5.0. 29 | ```` 30 | 31 | 4. Download and extract `text 2.19.0`. 32 | 33 | ```shell 34 | wget https://github.com/tensorflow/text/archive/refs/tags/v2.19.0.zip 35 | unzip ./v2.19.0.zip 36 | cd text-2.19.0 37 | ```` 38 | 39 | 5. Run the script. 40 | 41 | ```shell 42 | ./oss_scripts/run_build.sh 43 | ```` 44 | 45 | 6. [Please do not forget to install the whl file.](https://github.com/sun1638650145/Libraries-and-Extensions-for-TensorFlow-for-Apple-Silicon/issues/2) 46 | 47 | ```shell 48 | pip install ./*.whl 49 | ``` 50 | 51 | ## Tips&Refer 52 | 53 | 1. `Text` needs to correspond to a minor version of `tensorflow` (e.g. `tensorflow-macos==2.7.0` and `tensorflow-text==2.7.3`) 54 | 2. Please ensure that your network is stable during the compilation process, and the compilation needs to use the network. 55 | 3. [I add a PR for Apple Silicon support.](https://github.com/tensorflow/text/pull/756) 56 | --------------------------------------------------------------------------------