美文网首页
Faiss-GPU的编译在SwigFaiss遇到的问题

Faiss-GPU的编译在SwigFaiss遇到的问题

作者: afwer3 | 来源:发表于2019-10-12 21:23 被阅读0次

环境:Ubuntu16+Python3
在make后没有问题,make py以后则会报下面的错。问题在于swig3.0.8对于directives支持有问题,可以从swig官网直接下载3.0.12编译安装。apt库里最新的也只是3.0.8。

[@ironhide23586] That version of swig has trouble handling `using` directives. Please try with swig 3.0.12.

如何安装:

  1. 安装pcre。(sudo apt-get install libpcre3 libpcre3-dev)
  2. 去swig官网下载指定版本。http://www.swig.org/download.html
tar -zxvf swig-3.0.12.tar.gz
cd swig-3.0.12
# 默认的安装地址为/usr/local/share/
./configure
make
sudo make install

./configure --with-cuda="/usr/local/cuda-9.0" --with-cuda-arch="-gencode=arch=compute_61,code=compute_61"

附:

  1. gpu版本报错信息nvcc fatal : unsupported gpu architecture 'compute 75'。需要编辑上一步生成的makefile.inc文件,注释掉-gencode=arch=compute_75,code=compute_75这一行
  2. make 是用来编译的,它从Makefile中读取指令,然后编译
  3. make -j32在多核cpu上,并行编译是能够提高编译速度的
root@a77fad037489:/home/ubuntu/faiss16# make py
make -C python
make[1]: Entering directory '/home/ubuntu/faiss16/python'
swig -python -c++ -Doverride= -I../ -DSWIGWORDSIZE64 -DGPU_WRAPPER -o swigfaiss.cpp swigfaiss.swig
swigfaiss.swig:366: Warning 302: Identifier 'IndexShards' redefined (ignored) (Renamed from 'IndexShardsTemplate< faiss::Index >'),
../faiss/IndexShards.h:96: Warning 302: previous definition of 'IndexShards'.
swigfaiss.swig:367: Warning 302: Identifier 'IndexBinaryShards' redefined (ignored) (Renamed from 'IndexShardsTemplate< faiss::IndexBinary >'),
../faiss/IndexShards.h:97: Warning 302: previous definition of 'IndexBinaryShards'.
swigfaiss.swig:370: Warning 302: Identifier 'IndexReplicas' redefined (ignored) (Renamed from 'IndexReplicasTemplate< faiss::Index >'),
../faiss/IndexReplicas.h:73: Warning 302: previous definition of 'IndexReplicas'.
swigfaiss.swig:371: Warning 302: Identifier 'IndexBinaryReplicas' redefined (ignored) (Renamed from 'IndexReplicasTemplate< faiss::IndexBinary >'),
../faiss/IndexReplicas.h:74: Warning 302: previous definition of 'IndexBinaryReplicas'.
../faiss/MetaIndexes.h:24: Warning 315: Nothing known about 'IndexT::idx_t'.
../faiss/MetaIndexes.h:67: Warning 315: Nothing known about 'IndexT::idx_t'.
../faiss/MetaIndexes.h:67: Warning 315: Nothing known about 'IndexT::idx_t'.
swigfaiss.swig:374: Warning 302: Identifier 'IndexIDMap' redefined (ignored) (Renamed from 'IndexIDMapTemplate< faiss::Index >'),
../faiss/MetaIndexes.h:59: Warning 302: previous definition of 'IndexIDMap'.
swigfaiss.swig:375: Warning 302: Identifier 'IndexBinaryIDMap' redefined (ignored) (Renamed from 'IndexIDMapTemplate< faiss::IndexBinary >'),
../faiss/MetaIndexes.h:60: Warning 302: previous definition of 'IndexBinaryIDMap'.
swigfaiss.swig:376: Warning 302: Identifier 'IndexIDMap2' redefined (ignored) (Renamed from 'IndexIDMap2Template< faiss::Index >'),
../faiss/MetaIndexes.h:88: Warning 302: previous definition of 'IndexIDMap2'.
swigfaiss.swig:377: Warning 302: Identifier 'IndexBinaryIDMap2' redefined (ignored) (Renamed from 'IndexIDMap2Template< faiss::IndexBinary >'),
../faiss/MetaIndexes.h:89: Warning 302: previous definition of 'IndexBinaryIDMap2'.
g++ -std=c++11 -DFINTEGER=int  -fopenmp -I/usr/local/cuda-9.0/include  -fPIC -m64 -Wno-sign-compare -g -O3 -Wall -Wextra -mpopcnt -msse4 -I/usr/include/python3.6m -I/usr/include/python3.6m -I/usr/local/lib/python3.6/dist-packages/numpy/core/include \
               -I../ -c swigfaiss.cpp -o swigfaiss.o
swigfaiss.cpp: In function 'PyObject* _wrap_Index_ntotal_set(PyObject*, PyObject*)':
swigfaiss.cpp:18309:3: error: 'idx_t' was not declared in this scope
   idx_t arg2 ;
   ^
swigfaiss.cpp:18309:3: note: suggested alternative:
In file included from swigfaiss.cpp:3458:0:
../faiss/IVFlib.h:45:22: note:   'faiss::ivflib::idx_t'
 typedef Index::idx_t idx_t;
                      ^
swigfaiss.cpp:18331:15: error: 'temp' was not declared in this scope
       idx_t * temp = reinterpret_cast< idx_t * >(argp2);
               ^
swigfaiss.cpp:18331:40: error: 'idx_t' does not name a type
       idx_t * temp = reinterpret_cast< idx_t * >(argp2);
                                        ^
swigfaiss.cpp:18331:46: error: expected '>' before '*' token
       idx_t * temp = reinterpret_cast< idx_t * >(argp2);
                                              ^
swigfaiss.cpp:18331:46: error: expected '(' before '*' token
swigfaiss.cpp:18331:48: error: expected primary-expression before '>' token
       idx_t * temp = reinterpret_cast< idx_t * >(argp2);
                                                ^
swigfaiss.cpp:18331:56: error: expected ')' before ';' token
       idx_t * temp = reinterpret_cast< idx_t * >(argp2);
                                                        ^
swigfaiss.cpp:18332:7: error: 'arg2' was not declared in this scope
       arg2 = *temp;
       ^
swigfaiss.cpp:18333:39: error: type '<type error>' argument given to 'delete', expected pointer
       if (SWIG_IsNewObj(res2)) delete temp;
                                       ^
swigfaiss.cpp:18336:30: error: 'arg2' was not declared in this scope
   if (arg1) (arg1)->ntotal = arg2;
                              ^
swigfaiss.cpp: In function 'PyObject* _wrap_Index_ntotal_get(PyObject*, PyObject*)':
swigfaiss.cpp:18350:3: error: 'idx_t' was not declared in this scope
   idx_t result;
   ^
swigfaiss.cpp:18350:3: note: suggested alternative:
In file included from swigfaiss.cpp:3458:0:
../faiss/IVFlib.h:45:22: note:   'faiss::ivflib::idx_t'
 typedef Index::idx_t idx_t;
                      ^
swigfaiss.cpp:18358:3: error: 'result' was not declared in this scope
   result =  ((arg1)->ntotal);
   ^
swigfaiss.cpp:18359:39: error: expected type-specifier before 'idx_t'
   resultobj = SWIG_NewPointerObj((new idx_t(static_cast< const idx_t& >(result))), SWIGTYPE_p_idx_t, SWIG_POINTER_OWN |  0 );
                                       ^
swigfaiss.cpp:1188:89: note: in definition of macro 'SWIG_NewPointerObj'
 #define SWIG_NewPointerObj(ptr, type, flags)            SWIG_Python_NewPointerObj(NULL, ptr, type, flags)
                                                                                         ^
swigfaiss.cpp:18359:39: error: expected ')' before 'idx_t'
   resultobj = SWIG_NewPointerObj((new idx_t(static_cast< const idx_t& >(result))), SWIGTYPE_p_idx_t, SWIG_POINTER_OWN |  0 );
                                       ^
swigfaiss.cpp:1188:89: note: in definition of macro 'SWIG_NewPointerObj'
 #define SWIG_NewPointerObj(ptr, type, flags)            SWIG_Python_NewPointerObj(NULL, ptr, type, flags)
                                                                                         ^
swigfaiss.cpp: In function 'PyObject* _wrap_Index_train(PyObject*, PyObject*)':
swigfaiss.cpp:18617:3: error: 'idx_t' was not declared in this scope
   idx_t arg2 ;
   ^
swigfaiss.cpp:18617:3: note: suggested alternative:
In file included from swigfaiss.cpp:3458:0:
../faiss/IVFlib.h:45:22: note:   'faiss::ivflib::idx_t'
 typedef Index::idx_t idx_t;
                      ^
swigfaiss.cpp:18643:15: error: 'temp' was not declared in this scope
       idx_t * temp = reinterpret_cast< idx_t * >(argp2);
               ^
swigfaiss.cpp:18643:40: error: 'idx_t' does not name a type
       idx_t * temp = reinterpret_cast< idx_t * >(argp2);
                                        ^
swigfaiss.cpp:18643:46: error: expected '>' before '*' token
       idx_t * temp = reinterpret_cast< idx_t * >(argp2);
                                              ^

相关文章

网友评论

      本文标题:Faiss-GPU的编译在SwigFaiss遇到的问题

      本文链接:https://www.haomeiwen.com/subject/dgucmctx.html