Installation from Source Code
Obtain the source code, apply the patch for the Arm platform, and perform compilation and installation.
- Use PuTTY to log in to a server as the root user.
- Go to the ScaNN source code compilation directory.
1cd /path/to/scann
- Go to the ScaNN code directory.
1cd google-research/scann
- Install the dependencies.
1yum install rsync python python3-devel python3-pip gcc g++
- Configure the pip repository.
1 2
pip3 config set global.index-url https://mirrors.huaweicloud.com/repository/pypi/simple pip3 config set global.trusted-host mirrors.huaweicloud.com
- Add the Python 3 header file path to environment variables C_INCLUDE_PATH and CPLUS_INCLUDE_PATH. Set the parameters based on the actual installation path. For example:
1 2
export C_INCLUDE_PATH=/usr/include/python3.9:$C_INCLUDE_PATH export CPLUS_INCLUDE_PATH=/usr/include/python3.9:$CPLUS_INCLUDE_PATH
- Configure ScaNN compilation.
1python3 configure.py

If the command output shows that the configuration file .bazelrc is generated, the ScaNN compilation environment is successfully configured.
If "ModuleNotFoundError: No module named 'tensorflow'" is displayed when configuring the ScaNN compilation environment:

Run the ScaNN compilation environment configuration command again.
1python3 configure.py - Run the compilation command:
1bazel clean; CC=gcc bazel build -c opt --cxxopt="-std=c++17" --copt=-fsized-deallocation --copt=-w --copt=-O3 --cxxopt=-O3 --copt=-march=armv8.2-a+lse+sve+f64mm --cxxopt=-march=armv8.2-a+lse+sve+f64mm --copt=-msve-vector-bits=256 --cxxopt=-msve-vector-bits=256 :build_pip_pkg

If "unable to find valid certification path to requested target" is displayed when compiling ScaNN, rectify the fault by following instructions in The Certificate Path Cannot Be Found During ScaNN Compilation.
If "Python.h: no such file or directory" is displayed when compiling ScaNN, rectify the fault by following instructions in The Python.h File Is Not Available During ScaNN Compilation.
- Generate the .whl file of the ScaNN software package in the current path.
1./bazel-bin/build_pip_pkg
If the scann-1.2.10-cp39-cp39-linux_aarch64.whl file is generated in the current directory, the ScaNN software package is generated successfully.

- Install the ScaNN software package.
1pip3 install scann-1.2.10-cp39-cp39-linux_aarch64.whl
- Check whether ScaNN is successfully installed.
1python -c "import scann"

If no exception information is displayed, ScaNN is successfully installed.