|
1 | 1 | # Build TensorFlow Text from source
|
2 | 2 |
|
| 3 | +## Attention ⚠️ |
| 4 | + |
| 5 | +Please use `Xcode 14.3` and `Apple clang version 14.0.3 (clang-1403.0.22.14.1)`. |
| 6 | + |
3 | 7 | ## Necessary conditions
|
4 | 8 |
|
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 (such as M1, M1 Pro, M1 Max and M1 Ultra) build, so make sure your Mac is Apple Silicon. |
| 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. |
6 | 10 |
|
7 | 11 | ## Step by Step
|
8 | 12 |
|
9 | 13 | 1. Create a new Env and install the dependencies provided by Apple.
|
10 | 14 |
|
11 | 15 | ```shell
|
12 |
| - conda create -n tensorflow-macos python=3.9 # This Python version can also use 3.8 |
| 16 | + conda create -n tensorflow-macos python=3.10 # This Python version can also use 3.8 and 3.9 |
13 | 17 | conda activate tensorflow-macos
|
14 |
| - conda install -c apple tensorflow-deps==2.9.0 |
| 18 | + conda install -c apple tensorflow-deps==2.10.0 # Currently Apple has not released tensorflow-deps 2.11 and 2.12, 2.10 is the latest version. |
15 | 19 | ````
|
16 | 20 |
|
17 | 21 | 2. Install the `tensorflow-macos` and `tensorflow-metal` plugins.
|
18 | 22 |
|
19 | 23 | ```shell
|
20 |
| - pip install tensorflow-macos==2.9.0 |
21 |
| - pip install tensorflow-metal==0.5.0 |
| 24 | + pip install tensorflow-macos==2.12.0 |
| 25 | + pip install tensorflow-metal==0.8.0 |
22 | 26 | ````
|
23 | 27 |
|
24 |
| -3. Install `bazel 5.1.1`. |
| 28 | +3. Install `bazel 5.3.0`. |
25 | 29 |
|
26 | 30 | ```shell
|
27 |
| - wget https://raw.githubusercontent.com/Homebrew/homebrew-core/2940e900476b4452c8047c75dcbfc193c6f30341/Formula/bazel.rb |
| 31 | + wget https://raw.githubusercontent.com/Homebrew/homebrew-core/59dff37de3c670a77c1e9f39b8a4b0f8884a391b/Formula/bazel.rb |
28 | 32 | brew install ./bazel.rb
|
29 |
| - bazel --version # Make sure the version is 5.1.x. |
| 33 | + bazel --version # Make sure the version is 5.3.0. |
30 | 34 | ````
|
31 | 35 |
|
32 | 36 | * Usually, the `bazel` installed by `brew` will be the latest version. The latest version often does not match the version required by `text`, which may cause many unexpected problems, so we install it by specifying the version manually.
|
33 | 37 |
|
34 |
| -4. Download and extract `text 2.9.0`. |
| 38 | +4. Download and extract `text 2.12.0`. |
35 | 39 |
|
36 | 40 | ```shell
|
37 |
| - wget https://github.com/tensorflow/text/archive/refs/tags/v2.9.0.zip |
38 |
| - unzip ./v2.9.0.zip |
39 |
| - cd text-2.9.0 |
| 41 | + wget https://github.com/tensorflow/text/archive/refs/tags/v2.12.0.zip |
| 42 | + unzip ./v2.12.0.zip |
| 43 | + cd text-2.12.0 |
40 | 44 | ````
|
41 | 45 |
|
42 | 46 | 5. Modify some parameters of the source code to ensure correct build.
|
43 | 47 |
|
44 | 48 | * `oss_scripts/configure.sh` to modify line 49:
|
45 | 49 |
|
46 | 50 | ```shell
|
47 |
| - pip install tensorflow-macos==2.9.0 |
| 51 | + pip install tensorflow-macos==2.12.0 |
48 | 52 | ````
|
49 |
| - |
| 53 | + |
| 54 | + * (Optional, if you have not installed `bazel` through `brew`, please skip it) `oss_scripts/run_build.sh` modify line 19: |
| 55 | + |
| 56 | + ```shell |
| 57 | + tf_bazel_version='5.3.0-homebrew' |
| 58 | + ``` |
| 59 | + |
50 | 60 | 6. Run the script.
|
51 | 61 |
|
52 | 62 | ```shell
|
|
0 commit comments