Installing Bazel
Compiling TensorFlow Serving 2.15 depends on Bazel 6.5.0, which is different from the Bazel version required for compiling TensorFlow. Therefore, you need to install Bazel 6.5.0 separately.
- Use PuTTY to log in to a server as the root user.
- Go to the compilation path of the Bazel source code.
1cd /path/to/bazel
- Run the following command to install the Bazel dependency (if the Bazel dependency has been installed, skip to 6).
1yum install java-11-openjdk java-11-openjdk-devel
- Check whether OpenJDK 11 is successfully installed.
1java -version
If the command output contains the Java version information, the installation is successful.
An earlier OpenJDK version may cause an error during Bazel compilation.
- (Optional) If the preceding command output displays an incorrect version, configure environment variables.
- Search for the installation directory.
1find / -name java
- Configure environment variables. Assume that the installation directory is /usr/lib/jvm/java-11-openjdk-11.0.21.9-1.oe2203sp3.aarch64.
- Method 1 (permanently effective):
1 2 3
echo "export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-11.0.21.9-1.oe2203sp3.aarch64" >> /etc/profile echo "export PATH=\${JAVA_HOME}/bin:\${PATH}" >> /etc/profile source /etc/profile
- Method 2 (temporarily effective for the current session terminal):
1 2
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-11.0.21.9-1.oe2203sp3.aarch64 export PATH=/usr/lib/jvm/java-11-openjdk-11.0.21.9-1.oe2203sp3.aarch64/bin:$PATH
- Method 1 (permanently effective):
- Check the OpenJDK version.
1java -version
- Search for the installation directory.
- Download the Bazel 6.5.0 source code to the server.
1wget https://releases.bazel.build/6.5.0/release/bazel-6.5.0-dist.zip --no-check-certificate
- Decompress the Bazel source package and go to the decompressed directory.
1 2
unzip bazel-6.5.0-dist.zip -d bazel-6.5.0 cd bazel-6.5.0
- Build Bazel.
1env EXTRA_BAZEL_ARGS="--tool_java_runtime_version=local_jdk" bash ./compile.sh
- Install the executable to the /usr/local/bin/ directory (the executable is generated after the build process and is stored in the bazel-6.5.0/output directory).
1cp output/bazel /usr/local/bin/
- Check whether the installation is successful.
1bazel --help
If the command output contains the corresponding version information, the installation is successful.
Parent topic: Model Inference on TensorFlow Serving