Installing Bazel
The Bazel tool is required for TensorFlow compilation. TensorFlow 1.15.5 depends on Bazel 0.26.1. Download the correct Bazel version.
- Use PuTTY to log in to the server as the root user.
- Go to the compilation path for Bazel source code.
1cd /path/to/bazel
- Install dependencies for Bazel.
1yum install java-11-openjdk java-11-openjdk-devel
Check whether OpenJDK 11 is successfully installed.
1java -version
If the preceding information is displayed, 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 (effective permanently):
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 (effective for the current session):
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 (effective permanently):
- Check the OpenJDK version.
1java -version
- Search for the installation directory.
- Download the Bazel 0.26.1 source code to the server.
1wget https://github.com/bazelbuild/bazel/releases/download/0.26.1/bazel-0.26.1-dist.zip --no-check-certificate
- Decompress the Bazel source package and go to the decompressed directory.
1 2
unzip bazel-0.26.1-dist.zip -d bazel-0.26.1 cd bazel-0.26.1
- Decompress, compile, and install Bazel.
1env EXTRA_BAZEL_ARGS="--host_javabase=@local_jdk//:jdk" ./compile.sh
During the compression process, if an error is reported stating "ambiguating new declaration of 'long int gettid()", rectify this error by following instructions in Failed to Compile Bazel 0.26.1.
- After compilation, the bazel executable file is generated in bazel-0.26.1/output. Configure the path in the environment variable PATH for subsequent TensorFlow compilation.
1export PATH=/path/to/bazel/bazel-0.26.1/output:$PATH
- Verify the installation.
1bazel --help
If the correct version is displayed, the installation is successful.
Parent topic: Configuring the Compilation Environment