Skip to content

Creating two IndexPQ with specific parameters continuously causes unexpected termination #3803

@qwevdb

Description

@qwevdb

Summary

When creating two IndexPQ instances in a Python script with specific configuration parameters continuously, the script is unexpectedly killed during execution.

Platform

OS: Ubuntu 24.04 LTS

Faiss version: faiss-gpu 1.8.0

Installed from: Anaconda

Faiss compilation options:

Running on:

  • [✔] CPU
  • GPU

Interface:

  • C++
  • [✔] Python

Reproduction instructions

import faiss
import numpy as np

# Set parameters
d = 554
M = 1
nbits = 56
metric = faiss.METRIC_INNER_PRODUCT

index0 = faiss.IndexPQ(d, M, nbits, metric)
# Killed occurs here
index1 = faiss.IndexPQ(d, M, nbits, metric)

np.random.seed(0)
nb = 10000
nq = 1
xb = np.random.random((nb, d)).astype('float32')
xq = np.random.random((nq, d)).astype('float32')

index1.train(xb)
index1.add(xb)

k = 5
D, I = index1.search(xq, k)

print("Index:\n", I)
print("Distance:\n", D)

When running the above Python script, for unknown reason, the script itself gets killed as follow.

Killed

We have also observed that being killed is associated with the platform.
When the above Python script runs on the server with Ubuntu 24.04 LTS (Intel Core i7-11700 CPU and 64G memory), it gets killed.
However, the following errors occur when the script is running on the laptop with Ubuntu 22.04.3 LTS in WSL (AMD Ryzen 5 4600H CPU and 16G memory).

Traceback (most recent call last):
  File "/mnt/d/faiss/bug.py", line 12, in <module>
    index0 = faiss.IndexPQ(d, M, nbits, metric)
  File "/home/xxx/anaconda3/envs/faiss/lib/python3.10/site-packages/faiss/swigfaiss_avx2.py", line 5063, in __init__
    _swigfaiss_avx2.IndexPQ_swiginit(self, _swigfaiss_avx2.new_IndexPQ(*args))
MemoryError: std::bad_alloc

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions