Compilation and Installation
The patches for TF Serving thread scheduling optimization are now available in the open source TensorFlow and TF Serving repositories hosted on Gitee. You can clone these repositories via Git and proceed with compilation.
Obtaining Code
- Disable SSL verification for Git.
1 2
git config --global http.sslVerify false git config --global https.sslVerify false
- Pull the code.
1git clone https://gitee.com/openeuler/sra_tensorflow_adapter.git -b v2.15.0
Compiling
- Install GCC 12.3.1.
1yum install -y gcc-toolset-12-gcc*
- Go to the sra_tensorflow_adapter directory.
1cd sra_tensorflow_adapter/
- Create a directory for storing compilation dependencies. The path is /path/to/sra_tensorflow_adapter/serving/download.
1 2
export DISTDIR=$(pwd)/serving/download mkdir -p $DISTDIR
- Sets the path of the Bazel, which must point to the bazel executable file.
1export BAZEL_PATH=/path/to/bazel
- Run the build script to compile the code.
1sh compile_serving.sh gcc12
The build product is the TF Serving binary file tensorflow_model_server, and the file path is /path/to/sra_tensorflow_adapter/serving/bazel-bin/tensorflow_serving/model_servers/tensorflow_model_server.
In the preceding command, gcc12 indicates that GCC 12.3.1 is used for compilation. The compilation command in the build script is as follows:bazel --output_user_root=$BAZEL_COMPILE_CACHE build -c opt --distdir=$DISTDIR --override_repository=org_tensorflow=$TENSORFLOW_DIR --copt=-march=armv8.3-a+crc --copt=-O3 --copt=-fprefetch-loop-arrays --copt=-Wno-error=maybe-uninitialized --copt=-Werror=stringop-overflow=0 tensorflow_serving/model_servers:tensorflow_model_server
The following describes some parameters:
- output_user_root: Bazel compilation cache directory. The default value is /path/to/sra_tensorflow_adapter/serving/output. You can use the BAZEL_COMPILE_CACHE environment variable to set a custom path. The command is as follows:
1export BAZEL_COMPILE_CACHE=/path/to/your/cache_dir
- distdir: Directory for storing TF Serving compilation dependencies. It ensures reliable access when third-party package download fails.
- override_repository: Specifies the local TensorFlow build. The /path/to/sra_tensorflow_adapter/tensorflow directory is automatically identified as the build dependency.
Common build errors and solutions:
- If the message "unable to find valid certification path to requested target" is displayed, the certificate verification fails. For details about the solution, see Failed to Verify the Certificate When Compiling TensorFlow 2.13.0 Source Code in the TensorFlow Porting Guide.
- If the message "Error in download_and_extract" is displayed, rectify the fault by referring to Failed to Download the TF-Serving Source Code Dependency in the TensorFlow Serving Porting Guide. The directory specified by --distdir is /path/to/sra_tensorflow_adapter/serving/download.
- If the system displays a message indicating that the org_boost dependency library fails to be pulled, see Failed to Obtain the Dependency of the org_boost Sub-repository in the TensorFlow Serving Porting Guide.
- f the system displays a message indicating that no Golang website certificate is available, rectify the fault by referring to No Golang Website Certificate in the TensorFlow Serving Porting Guide.
- If the system displays a message indicating that an error occurs during upd.c compilation, rectify the fault by referring to Syntax Error Reported During upb.c Compilation in the TensorFlow Serving Porting Guide.
- output_user_root: Bazel compilation cache directory. The default value is /path/to/sra_tensorflow_adapter/serving/output. You can use the BAZEL_COMPILE_CACHE environment variable to set a custom path. The command is as follows:
Parent topic: Developer Guide