faiss icon indicating copy to clipboard operation
faiss copied to clipboard

Cant set parameters when using GPU

Open rafayaar opened this issue 2 years ago • 0 comments

Summary

Why cant we set nprobe, efSearch and ht using GpuParameterSpace() Following is my code:

import faiss
import numpy as np

random_vectors = np.random.rand(10000, 768).astype('float32')#dummy data
co = faiss.GpuMultipleClonerOptions()
co.useFloat16 = True
INDEX = faiss.index_factory(768, "OPQ64_128,IVF256_HNSW32,PQ64")
INDEX = faiss.index_cpu_to_all_gpus(INDEX, co)

faiss.normalize_L2(random_vectors)
INDEX.train(random_vectors)

ps = faiss.GpuParameterSpace()
ps.initialize(INDEX)
ps.set_index_parameters(INDEX, "nprobe=4096,quantizer_efSearch=512,ht=512")

INDEX.add(random_vectors)
...

It works fine without using GPU, but it takes forever to process I have d = 768 and around 6 million vecs for training. It gives following errors.

RuntimeError: Error in virtual void faiss::ParameterSpace::set_index_parameter(faiss::Index*, const string&, double) const at /project/faiss/faiss/AutoTune.cpp:550: ParameterSpace::set_index_parameter:could not set parameter quantizer_efSearch

RuntimeError: Error in virtual void faiss::ParameterSpace::set_index_parameter(faiss::Index*, const string&, double) const at /project/faiss/faiss/AutoTune.cpp:550: ParameterSpace::set_index_parameter:could not set parameter ht Only thing I can manage to set is nprobe which I can't go more then 2048.

Platform

OS: Ubuntu LTS 20

Faiss version: faiss-gpu (1.7.2)

Installed from: pip

Running on:

  • [ ] CPU
  • [x] GPU

Interface:

  • [ ] C++
  • [x] Python

rafayaar avatar Dec 15 '23 11:12 rafayaar