主要是基于官网教程,在安装过程中有一些注意事项,在这里做一下说明(强烈推荐参考github给出的官方教程,非常详细,一步一步执行即可,链接https://github.com/facebookresearch/faiss/blob/master/INSTALL.md)
环境:ubunt 16.04,anaconda2(python2.7),gtx1050ti,cuda8.0 ,cudnn 6.0
首先是安装cuda8.0 和cudnn6.0,和其他所有的深度学习框架需要的一样,参考本博客其他教程
1,安装openblas
conda install openblas
2, 下载faiss,修改makefile.inc文件
- # 下载FAISS源码
- git clone https://github.com/facebookresearch/faiss.git
- # 进入FAISS源码目录
- cd faiss
- # 根据系统配置编译环境
- cp example_makefiles/makefile.inc.Linux ./makefile.inc
这里需要进到 faiss目录下的makefile.inc里手动修改,文件中默认使用的是centos,需要把centos部分注释掉,并取消ubuntu16.04的注释
这里给出 修改后的makefile.inc的文件内容:
# Copyright (c) 2015-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the BSD+Patents license found in the
# LICENSE file in the root directory of this source tree.
# -*- makefile -*-
# tested on CentOS 7, Ubuntu 16 and Ubuntu 14, see below to adjust flags to distribution.
CC=gcc
CXX=g++
CFLAGS=-fPIC -m64 -Wall -g -O3 -mavx -msse4 -mpopcnt -fopenmp -Wno-sign-compare -fopenmp
CXXFLAGS=$(CFLAGS) -std=c++11
LDFLAGS=-g -fP