Skip to content

Instantly share code, notes, and snippets.

@w32zhong
Last active April 17, 2022 10:46
Show Gist options
  • Save w32zhong/143c2b912ce8c6630963fad488885e72 to your computer and use it in GitHub Desktop.
Save w32zhong/143c2b912ce8c6630963fad488885e72 to your computer and use it in GitHub Desktop.
Build Faiss-cpu on IBM Power9 CPU
# See https://github.com/facebookresearch/faiss/blob/main/INSTALL.md#step-1-invoking-cmake
PREFIX=/gpfs/fs1/home/j/jimmylin/w32zhong/.conda/envs/py38/powerpc64le-conda_cos7-linux-gnu
#MYLIB=/gpfs/fs1/home/j/jimmylin/w32zhong/OpenBLAS-0.3.17/libopenblas.a
MYLIB=/gpfs/fs1/home/j/jimmylin/w32zhong/faiss/flexiblas-3.0.3/build/lib/libflexiblas.so
module load cmake/3.19.8
cmake -B build . -DFAISS_ENABLE_GPU=OFF -DBLAS_LIBRARIES=$MYLIB -DLAPACK_LIBRARIES=$MYLIB -DBUILD_SHARED_LIBS=OFF
make -C build -j faiss VERBOSE=1
make -C build -j swigfaiss VERBOSE=1
(cd build/faiss/python && python setup.py install)
# If build from source, and use Anaconda env, be aware of gcc linked libs
module load gcc/10.3.0
gcc -print-file-name=libstdc++.so # /scinet/mist/rhel8/software/2021a/opt/base/gcc/10.3.0/lib64/../lib64/libstdc++.so
strings /scinet/mist/rhel8/software/2021a/opt/base/gcc/10.3.0/lib64/../lib64/libstdc++.so | grep ^GLIBCXX_3.4.26
# To install Anaconda compile tools for Power PC CPU:
conda install gcc_linux-ppc64le
conda install gxx_linux-ppc64le
(py38) w32zhong ~ 1 echo $CC
/home/j/jimmylin/w32zhong/.conda/envs/py38/bin/powerpc64le-conda_cos7-linux-gnu-cc
(py38) w32zhong ~ $ echo $CXX
/home/j/jimmylin/w32zhong/.conda/envs/py38/bin/powerpc64le-conda_cos7-linux-gnu-c++
(py38) w32zhong ~/faiss-1.7.1 $ echo $CXXFLAGS
-fvisibility-inlines-hidden -std=c++17 -fmessage-length=0 -mcpu=power8 -mtune=power8 -mpower8-fusion -mpower8-vector -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O3 -pipe -isystem /home/j/jimmylin/w32zhong/.conda/envs/py38/include
(py38) w32zhong ~/faiss-1.7.1 $ echo $CFLAGS
-mcpu=power8 -mtune=power8 -mpower8-fusion -mpower8-vector -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O3 -pipe -isystem /home/j/jimmylin/w32zhong/.conda/envs/py38/include
export CFLAGS="$CFLAGS -I /gpfs/fs1/home/j/jimmylin/w32zhong/.conda/envs/py38/include"
export CXXFLAGS="$CXXFLAGS -I /gpfs/fs1/home/j/jimmylin/w32zhong/.conda/envs/py38/include"
export LDFLAGS="$LDFLAGS -L /gpfs/fs1/home/j/jimmylin/w32zhong/.conda/envs/py38/lib/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment