Porting TensorFlow 2.4.1
Procedure
- Create a TensorFlow build environment.
conda create -n bazel_build bazel=3.7 python=3.7.12 -c conda-forge
- Activate the build environment.
conda activate bazel_build
- Install the build dependencies.
conda install -c conda-forge keras-preprocessing=1.1.2 numpy=1.18.5
- Download the TensorFlow 2.4.1 source code.
git clone https://github.com/tensorflow/tensorflow.git -b v2.4.1
- Go to the source code directory.
cd tensoflow
- Configure the build environment.
python configure.py

- Compile the source code.
bazel build //tensorflow/tools/pip_package:build_pip_package
Due to network problems, many resources cannot be automatically obtained during bazel build. You need to download the required resources and change the URLs in the build file to the local paths. For details, see Many Resources Fail to Be Automatically Obtained for Bazel Build When Porting TensorFlow 2.4.1.
- Build the local conda package of TensorFlow.
bazel-bin/tensorflow/tools/pip_package/build_pip_package /path/to/tensorflow
The built TensorFlow installation package is stored in the /path/to/tensorflow directory.

Parent topic: Configuring the Compilation Environment