Skip to content

Commit 00e2735

Browse files
poinwaterrhdong
authored andcommitted
[doc]Add Apple Silicon installation instruction && fix typo
1 parent d4a78d4 commit 00e2735

File tree

2 files changed

+57
-8
lines changed

2 files changed

+57
-8
lines changed

README.md

Lines changed: 56 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,20 @@
77

88
TensorFlow Recommenders Addons(TFRA) are a collection of projects related to large-scale recommendation systems
99
built upon TensorFlow by introducing the **Dynamic Embedding Technology** to TensorFlow
10-
that makes TensorFlow more suitable for trainning models of **Search, Recommendations and Advertising** and
10+
that makes TensorFlow more suitable for training models of **Search, Recommendations, and Advertising** and
1111
makes building, evaluating, and serving sophisticated recommenders models easy.
1212
See approved TensorFlow RFC #[313](https://github.com/tensorflow/community/pull/313).
1313
Those contributions will be complementary to TensorFlow Core and TensorFlow Recommenders etc.
1414

15+
For Apple silicon(M1), please refer to [Apple Silicon Support](#apple-silicon-support-beta-release).
16+
1517
## Main Features
1618

1719
- Make key-value data structure (dynamic embedding) trainable in TensorFlow
1820
- Get better recommendation effect compared to static embedding mechanism with no hash conflicts
1921
- Compatible with all native TensorFlow optimizers and initializers
2022
- Compatible with native TensorFlow CheckPoint and SavedModel format
21-
- Fully support train and inference recommeneders models on GPUs
23+
- Fully support train and inference recommenders models on GPUs
2224
- Support [TF serving](https://github.com/tensorflow/serving) and [Triton Inference Server](https://github.com/triton-inference-server/server) as inference framework
2325
- Support variant Key-Value implements as dynamic embedding storage and easy to extend
2426
- [cuckoohash_map](https://github.com/efficient/libcuckoo) (from Efficient Computing at Carnegie Mellon, on CPU)
@@ -114,7 +116,8 @@ is compiled differently. A typical example of this would be `conda`-installed Te
114116
Check [nvidia-support-matrix](https://docs.nvidia.com/deeplearning/cudnn/support-matrix/index.html) for more details.
115117

116118
**NOTICE**
117-
- The release packages have strict version binding relationship with TensorFlow.
119+
120+
- The release packages have a strict version binding relationship with TensorFlow.
118121
- Due to the significant changes in the Tensorflow API, we can only ensure version 0.2.0 compatibility with TF1.15.2 on CPU & GPU,
119122
but **there are no official releases**, you can only get it through compiling by the following:
120123
```shell
@@ -127,7 +130,7 @@ sh .github/workflows/make_wheel_Linux_x86.sh
127130
```
128131

129132
- If you need to work with TensorFlow 1.14.x or older version, we suggest you give up,
130-
but maybe this doc can help you : [Extract headers from TensorFlow compiling dirctory](./build_deps/tf_header/README.md).
133+
but maybe this doc can help you : [Extract headers from TensorFlow compiling directory](./build_deps/tf_header/README.md).
131134
At the same time, we find some OPs used by TRFA have better performance, so we highly recommend you update TensorFlow to 2.x.
132135

133136
#### Installing from Source
@@ -136,7 +139,7 @@ You can also install from source. This requires the [Bazel](https://bazel.build/
136139
Please install a TensorFlow on your compiling machine, The compiler needs to know the version of Tensorflow and
137140
its headers according to the installed TensorFlow.
138141

139-
```
142+
```shell
140143
export TF_VERSION="2.5.1" # "2.7.0", "2.5.1" are well tested.
141144
pip install tensorflow[-gpu]==$TF_VERSION
142145

@@ -169,8 +172,53 @@ bazel build --enable_runfiles build_pip_pkg
169172
TF_NEED_CUDA=1 bazel-bin/build_pip_pkg artifacts
170173
pip install artifacts/tensorflow_recommenders_addons_gpu-*.whl
171174
```
175+
##### Apple Silicon Support (Beta Release)
176+
Requirements:
177+
178+
- macOS 12.0.0+
179+
- Python 3.8 or 3.9
180+
- tensorflow-macos 2.5.0
181+
- bazel 4.1.0+
182+
183+
Before installing **TFRA** from source, you need to install tensorflow-macos from Apple. To install the natively supported version of tensorflow-macos, it's required to install the [Conda environment](https://github.com/conda-forge/miniforge).
184+
185+
After installing conda environment, run the following commands in the terminal.
186+
187+
```sh
188+
# Create a virtual environment
189+
conda create -n $YOUR-ENVIRONMENT-NAME Python=$PYTHON_VERSION
190+
191+
# Activate your environment
192+
conda activate $YOUR-ENVIRONMENT-NAME
193+
194+
# Install TensorFlow macOS dependencies via miniforge
195+
conda install -c apple tensorflow-deps==2.5.0
196+
197+
# Install base TensorFlow
198+
python -m pip install tensorflow-macos==2.5.0
199+
200+
# Install TensorFlow Recommenders Addons from PyPi distribution (optional)
201+
python -m pip install tensorflow-recommenders-addons --no-deps
202+
```
203+
204+
There is a difference between the [tensorflow-macos installation instruction](https://developer.apple.com/metal/tensorflow-plugin/) and our instruction because this build requires Python 3.8 or 3.9 and tensorflow-macos 2.5.0.
205+
206+
The building script has been tested on macOS Monterey, If you are using macOS Big Sur, you may need to customize the building script.
207+
208+
```shell
209+
# Build arm64 wheel from source
210+
PY_VERSION=$PYTHON_VERSION TF_VERSION="2.5.0" TF_NEED_CUDA="0" sh .github/workflows/make_wheel_macOS_arm64.sh
211+
212+
# Install
213+
python -m pip install --no-deps ./artifacts/*.whl
214+
```
215+
216+
**NOTICE:**
217+
218+
- The Apple silicon version TFRA doesn't support data type **float16**, the issue may be fixed in the future release.
172219

173220
##### Data Type Matrix for `tfra.dynamic_embedding.Variable`
221+
174222
| Values \\ Keys | int64 | int32 | string |
175223
|:----:|:----:|:----:|:----:|
176224
| float | CPU, GPU | CPU, GPU | CPU |
@@ -184,7 +232,8 @@ pip install artifacts/tensorflow_recommenders_addons_gpu-*.whl
184232

185233
##### To use GPU by `tfra.dynamic_embedding.Variable`
186234
The `tfra.dynamic_embedding.Variable` will ignore the device placement mechanism of TensorFlow,
187-
you should specify the `devices` onto GPUs explictly for it.
235+
you should specify the `devices` onto GPUs explicitly for it.
236+
188237
```python
189238
import tensorflow as tf
190239
import tensorflow_recommenders_addons as tfra
@@ -246,6 +295,6 @@ SUPPORTED_TENSORFLOW_OPS = if_v2([]) + if_not_v2([
246295
We are very grateful to the maintainers of [tensorflow/addons](https://github.com/tensorflow/addons) for borrowing a lot of code from [tensorflow/addons](https://github.com/tensorflow/addons) to build our workflow and documentation system.
247296
We also want to extend a thank you to the Google team members who have helped with CI setup and reviews!
248297

249-
## Licence
298+
## License
250299
Apache License 2.0
251300

build_deps/tf_header/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Extract headers from TensorFlow compiling dirctory
1+
# Extract headers from TensorFlow compiling directory
22
-----------------
33

44
For some C++ headers needed by TFRA are not included in installation directory of old version Tensorflow.

0 commit comments

Comments
 (0)