Rate This Document
Findability
Accuracy
Completeness
Readability

Installing Bazel

ScaNN uses the Bazel compilation framework. The Bazel version must be 5.4.0 or later; however, the Bazel version installed using Yum is too early. Therefore, you need to compile and install Bazel using the source code.

  1. Use PuTTY to log in to the server as the root user.
  2. Go to the Bazel source code compilation directory.
    1
    cd /path/to/bazel/
    
  3. Download the Bazel 5.4.0 source code to the directory.

    https://github.com/bazelbuild/bazel/releases/download/5.4.0/bazel-5.4.0-dist.zip

    You can run the wget command to download it.

    1
    wget https://github.com/bazelbuild/bazel/releases/download/5.4.0/bazel-5.4.0-dist.zip --no-check-certificate
    
  4. Install dependencies for Bazel.
    1
    yum install java-11-openjdk java-11-openjdk-devel gcc git g++
    

    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.

  5. (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 (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
        
    3. Check the OpenJDK version.
      1
      java -version
      
  6. Decompress and compile Bazel.
    1
    2
    3
    unzip bazel-5.4.0-dist.zip -d bazel-5.4.0
    cd bazel-5.4.0
    env EXTRA_BAZEL_ARGS="--tool_java_runtime_version=local_jdk" bash ./compile.sh
    
  7. After compilation, the bazel executable file is generated in bazel-5.4.0/output. Configure the path in the environment variable PATH for subsequent ScaNN compilation.
    1
    export PATH=/path/to/bazel/bazel-5.4.0/output:$PATH
    
  8. Perform the verification.
    1
    bazel --version
    

    If the command output shows that the version is 5.4.0, the installation is successful.