FAISS GPU 索引
FAISS GPU 索引
import faiss
res = faiss.StandardGpuResources()
cpu_index = faiss.IndexFlatIP(768)
gpu_index = faiss.index_cpu_to_gpu(res, 0, cpu_index)
gpu_index.add(np.random.rand(1000000, 768).astype("float32"))
D, I = gpu_index.search(np.random.rand(256, 768).astype("float32"), 10) # 批量查询要核对 faiss 与 CUDA、驱动的版本匹配;显存不足时迁回分片或量化方案。