Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add_with_ids fails on GPU but works after moving the index to the CPU, is this expected? #3631

Open
3 of 4 tasks
sniklaus opened this issue Jul 12, 2024 · 4 comments
Open
3 of 4 tasks

Comments

@sniklaus
Copy link

Summary

add_with_ids fails on GPU but works after moving the index to the CPU, is this expected? Thank you in advance!

Platform

OS: nvidia/cuda:12.1.1-devel-ubuntu22.04

Faiss version: 1.8.0 / py3.11_hedc54c9_0_cuda11.4.4

Installed from: conda install -c pytorch -c nvidia faiss-gpu -y

Faiss compilation options: N/A

Running on:

  • CPU
  • GPU

Interface:

  • C++
  • Python

Reproduction instructions

import faiss
import numpy
idx = faiss.index_factory(1024, 'OPQ48_336,IVF131072,PQ48x8', faiss.METRIC_INNER_PRODUCT)
idx = faiss.index_cpu_to_all_gpus(idx)
idx.train(numpy.random.rand(131072, 1024).astype(numpy.float32))
idx.add_with_ids(numpy.random.rand(3, 1024).astype(numpy.float32), numpy.array([4, 5, 6], numpy.int64)) # fails
idx = faiss.index_gpu_to_cpu(objIndex)
idx.add_with_ids(numpy.random.rand(3, 1024).astype(numpy.float32), numpy.array([4, 5, 6], numpy.int64)) # works
@ramilbakhshyiev
Copy link
Contributor

Hi @sniklaus, is this the error message that you're getting?

RuntimeError:Error in virtual void faiss::Index::add_with_ids(faiss::idx_t, const float *, const faiss::idx_t *) at fbcode/faiss/Index.cpp:45: add_with_ids not implemented for this type of index

@sniklaus
Copy link
Author

That's exactly it. 👍

@sniklaus
Copy link
Author

It is just surprising that it works just fine on the CPU and I am not sure whether it is by design or whether it is a bug.

@ramilbakhshyiev
Copy link
Contributor

@sniklaus I pinged our GPU group to take a look at this. Thanks for reporting this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants