Skip to content

Instantly share code, notes, and snippets.

@mdouze
mdouze / gist:9694e8ec06a8d71add0630ce4e0ea294
Created March 22, 2017 09:49
Exact search perf with OpenBLAS.
In [1]: import numpy as np
In [2]: import faiss
Failed to load GPU Faiss: No module named swigfaiss_gpu
Faiss falling back to CPU-only.
In [3]: import time
In [4]:
@mdouze
mdouze / gist:9a392de0de81614ea2f39b8c724597a3
Created March 22, 2017 09:56
Search perf OpenBLAS with OMP_WAIT_POLICY=PASSIVE
OMP_WAIT_POLICY=PASSIVE ipython
Python 2.7.5 (default, Nov 6 2016, 00:28:07)
Type "copyright", "credits" or "license" for more information.
IPython 3.2.1 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
import numpy as np
import time
import faiss
import os
#################################################################
# I/O functions
#################################################################
def ivecs_read(fname):
[matthijs@matthijs-mbp ~/Desktop/test_cmake/faiss/build]cmake -DCMAKE_CXX_COMPILER=/opt/local/bin/g++-mp-6 ..
-- The C compiler identification is AppleClang 8.0.0.8000042
-- The CXX compiler identification is GNU 6.3.0
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Checking whether CXX compiler has -isysroot
diff --git a/faiss/swigfaiss.swig b/faiss/swigfaiss.swig
--- a/faiss/swigfaiss.swig
+++ b/faiss/swigfaiss.swig
@@ -548,6 +548,10 @@
return NULL;
}
+float * cast_integer_to_float_ptr (long x) {
+ return (float*)x;
+}
import numpy as np
import torch
import faiss
# make a GPU index
d = 16
nq = 5
#! /usr/bin/env python2
import numpy as np
import faiss
import time
xd = 100
yd = 1000000
np.random.seed(1234)
--[[ Copyright 2004-present Facebook. All Rights Reserved.
Load the dynamic library involved in swig calls for Faiss
+ some code to convert input / output arguments
the standard way of importing this is
swigfaiss = require 'faiss_swig'
if you require 'swigfaiss' directly, you get the indexing
structures without the additions that make them easy to use from
@mdouze
mdouze / -
Last active November 22, 2017 09:45 — forked from anonymous/-
matthijs@devfair004:~/faiss_py3_cuda9/gpu$ make -j10
g++ -std=c++11 -fPIC -m64 -Wall -g -Wno-sign-compare -O3 -fopenmp \
-c GpuResources.cpp -o GpuResources.o -I/public/apps/cuda/9.0//include
g++ -std=c++11 -fPIC -m64 -Wall -g -Wno-sign-compare -O3 -fopenmp \
-c IndexProxy.cpp -o IndexProxy.o -I/public/apps/cuda/9.0//include
g++ -std=c++11 -fPIC -m64 -Wall -g -Wno-sign-compare -O3 -fopenmp \
-c StandardGpuResources.cpp -o StandardGpuResources.o -I/public/apps/cuda/9.0//include
g++ -std=c++11 -fPIC -m64 -Wall -g -Wno-sign-compare -O3 -fopenmp \
-c GpuAutoTune.cpp -o GpuAutoTune.o -I/public/apps/cuda/9.0//include
matthijs@devfair0144:~/faiss_versions/alex_bug$ /public/apps/cuda/8.0//bin/nvcc -I. -I /public/apps/cuda/8.0//targets/x86_64-linux/include/ -Xcompiler -fPIC -Xcudafe --diag_suppress=unrecognized_attribute -gencode arch=compute_60,code="compute_60" -gencode arch=compute_61,code="compute_61" --std c++11 -lineinfo -ccbin g++ -DFAISS_USE_FLOAT16 -o tt tt.cpp faiss/gpu/libgpufaiss.a faiss/libfaiss.a -Xcompiler -fopenmp -lcublas -Xlinker --no-as-needed -Xlinker -rpath,/public/apps/anaconda2/5.0.1/lib/ -L/public/apps/anaconda2/5.0.1/lib/ -lmkl_intel_lp64 -lmkl_core -lmkl_gnu_thread -ldl -lpthread
matthijs@devfair0144:~/faiss_versions/alex_bug$ ./tt
Faiss assertion 'err__ == cudaSuccess' failed in faiss::gpu::DeviceTensor<T, Dim, InnerContig, IndexT, PtrTraits>::~DeviceTensor() [with T = float; int Dim = 3; bool InnerContig = true; IndexT = int; PtrTraits = faiss::gpu::traits::DefaultPtrTraits] at impl/../utils/DeviceTensor-inl.cuh:61; details: CUDA error 77
Aborted