sudo apt install swig


git clone https://github.com/facebookresearch/faiss.git
cd faiss
./configure  --with-cuda=/usr/local/cuda-10.0  --with-python=/usr/bin/python3.6 --host=aarch64-linux-gnu

将makefile.inc中PYTHONCFLAGS那一行,写成PYTHONCFLAGS = -I/usr/include/python3.6

NVCCFLAGS    = -I $(CUDA_ROOT)/targets/aarch64-linux/include/ \

# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

CXX          = aarch64-linux-gnu-g++ -std=c++11
CXXCPP       = aarch64-linux-gnu-g++ -std=c++11 -E
CPPFLAGS     = -DFINTEGER=int  -fopenmp -I/usr/local/cuda-10.0/include 
CXXFLAGS     = -fPIC  -Wno-sign-compare -g -O3 -Wall -Wextra
CPUFLAGS     = -march=armv8.2-a
LDFLAGS      = -fopenmp  -L/usr/local/cuda-10.0/lib64 
LIBS         = -lopenblas   -lcudart -lcublas 
PYTHONCFLAGS =   -I/usr/include/python3.6
SWIGFLAGS    = -DSWIGWORDSIZE64

NVCC         = /usr/local/cuda-10.0/bin/nvcc
CUDA_ROOT    = /usr/local/cuda-10.0
CUDA_ARCH    = -gencode=arch=compute_52,code=compute_52
NVCCFLAGS    = -I $(CUDA_ROOT)/targets/aarch64-linux/include/ \
-Xcompiler -fPIC \
-Xcudafe --diag_suppress=unrecognized_attribute \
$(CUDA_ARCH) \
-lineinfo \
-ccbin $(CXX) -DFAISS_USE_FLOAT16

OS = $(shell uname -s)

SHAREDEXT   = so
SHAREDFLAGS = -shared

ifeq ($(OS),Darwin)
	SHAREDEXT   = dylib
	SHAREDFLAGS = -dynamiclib -undefined dynamic_lookup
        SWIGFLAGS   =
endif

MKDIR_P      = /bin/mkdir -p
PYTHON       = 
SWIG         = swig
AR          ?= ar

prefix      ?= /usr/local
exec_prefix ?= ${prefix}
libdir       = ${exec_prefix}/lib
includedir   = ${prefix}/include

 

make
make install
make py
会报错,说setup.py有问题。进入到python目录下,vi setup.py,修改check_fpath这一行,改为check_fpath = os.path.join(here, "_swigfaiss.so")
python setup.py build
sudo python setup.py install
cd ..

Logo

鸿蒙生态一站式服务平台。

更多推荐