美文网首页
Faiss Python2 Linux子系统 编译

Faiss Python2 Linux子系统 编译

作者: afwer3 | 来源:发表于2019-06-28 15:56 被阅读0次

    系统:win10+linux子系统+ubuntu16.04
    Faiss: 1.5.0 (https://github.com/facebookresearch/faiss/archive/v1.5.0.zip)
    Python:Anaconda2+python2.7 && 直接python2.7

    编译

    1. 安装anaconda2 (bash Anaconda2-5.3.1-Linux-x86_64.sh)
    2. 安装make、swig、blas和g++ (sudo apt install make g++ swig libopenblas-dev)
    3. 进入faiss的目录 (./configure) 不需要手动复制makefile文件。另外可能需要手动修改执行命令后的makefile里的python目录。
    PYTHONCFLAGS = -I/home/x/anaconda2/include/python2.7 -I/home/x/anaconda2/lib/python2.7/site-packages/numpy/core/include
    PYTHON       = /home/x/anaconda2/bin/python
    
    1. 执行编译(make && sudo make install)
    2. 编译python (sudo make py && sudo make py install) 如果提示没有setuptools,使用(sudo apt install python-pip就行了)
    3. 添加faiss-python的全局变量,有两种方式,一种是修改.bashrc(export PYTHONPATH=/mnt/d/github/faiss/python),一种是在python文件里(import sys
      sys.path.append('/mnt/d/github/faiss/python'))。

    测试

    1. 测试c++版本是否编译成功 (demos/demo_ivfpq_indexing)
    2. 测试python是否编译成功 (python -c "import faiss") 可能需要进入到faiss/python目录里进行测试,如果没有设置faiss-python全局变量。

    相关文章

      网友评论

          本文标题:Faiss Python2 Linux子系统 编译

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