kyamagu / faiss-wheels

Unofficial faiss wheel builder

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Get a CUDA error when searching in a Faiss index having too small vectors

hayj opened this issue · comments

Describe the bug
Get a CUDA error when searching in a Faiss index having too small vectors

Faiss assertion 'err__ == cudaSuccess' failed in void faiss::gpu::ivfInterleavedScanImpl_32_(faiss::gpu::Tensor<float, 2, true>&, faiss::gpu::Tensor<long int, 2, true>&, faiss::gpu::DeviceVector<void*>&, faiss::gpu::DeviceVector<void*>&, faiss::gpu::IndicesOptions, faiss::gpu::DeviceVector<int>&, int, faiss::MetricType, bool, faiss::gpu::Tensor<float, 3, true>&, faiss::gpu::GpuScalarQuantizer*, faiss::gpu::Tensor<float, 2, true>&, faiss::gpu::Tensor<long int, 2, true>&, faiss::gpu::GpuResources*) at /project/faiss/faiss/gpu/impl/scan/IVFInterleaved32.cu:13; details: CUDA error 9 invalid configuration argument
        Aborted (core dumped)

or

Faiss assertion 'err__ == cudaSuccess' failed in int faiss::gpu::getNumDevices() at /project/faiss/faiss/gpu/utils/DeviceUtils.cu:36; details: CUDA error 401 the operation cannot be performed in the present state

To Reproduce

import faiss
import numpy as np
nb_vectors = 80_000
dim = 128
k = 5
nlist = 10
nprobe = 2
vectors = np.random.rand(nb_vectors, dim)
index = faiss.index_factory(dim, "IVF16384,Flat")
index.nlist = nlist
index.nprobe = nprobe
options = faiss.GpuMultipleClonerOptions()
options.shard = True
options.common_ivf_quantizer = True
index = faiss.index_cpu_to_all_gpus(index, options)
index.train(vectors)
index.add(vectors)
results = index.search(vectors, k)

This code works with dim = 1024.

I also tried with different indexes and different parameters (nlist, etc.) but it always fails for a certain vector size (and not when increasing the size).

When I try to install different versions of Faiss (nightly and old version) I face incompatibility issues such as:

AttributeError: module 'faiss._swigfaiss' has no attribute 'delete_ParameterRangeVector'

or

TypeError: in method 'GpuIndexIVFFlat_train', argument 3 of type 'float const *'

Desktop:

Solved it, pls refer to facebookresearch/faiss#3062