Rate This Document
Findability
Accuracy
Completeness
Readability

Installing Bazel

Bazel is a fast and scalable build tool. Before compiling TF-Serving, install Bazel.

  1. Use PuTTY to log in to a server as the root user.
  2. Go to the installation path of the Bazel source code.
    1
    cd /path/to/bazel
    
  3. Install the Bazel dependencies.
    1
    yum install java-11-openjdk java-11-openjdk-devel
    

    Check whether OpenJDK 11 is successfully installed.

    1
    java -version
    

    If the preceding information is displayed, the installation is successful.

    An earlier OpenJDK version may cause an error during Bazel compilation.

  4. (Optional) If the preceding command output displays an incorrect version, configure environment variables.
    1. Search for the installation directory.
      1
      find / -name java
      
    2. 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 on 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
        
    3. Check the OpenJDK version.
      1
      java -version
      
  5. Download the Bazel 6.5.0 source code to the server.
    1
    wget https://releases.bazel.build/6.5.0/release/bazel-6.5.0-dist.zip  --no-check-certificate
    
  6. 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
    
  7. Install, decompress, and compile Bazel.
    1
    env EXTRA_BAZEL_ARGS="--tool_java_runtime_version=local_jdk" bash ./compile.sh
    
  8. After the build is successful, the generated executable file bazel is stored in the bazel-6.5.0/output path. Configure the path in the environment variable PATH for subsequent TF-Serving compilation.
    1
    export PATH=/path/to/bazel/bazel-6.5.0/output:$PATH
    
  9. Check whether the installation is successful.
    1
    bazel --help
    

    If the correct version is displayed, the installation is successful.