facebookresearch / faiss

A library for efficient similarity search and clustering of dense vectors.
https://faiss.ai
MIT License
31.57k stars 3.65k forks source link

munmap_chunk(): invalid pointer \n segmentation fault (core dump), when feature dim is big in index.train #4038

Open cywuuuu opened 2 days ago

cywuuuu commented 2 days ago

Summary

I am trying to run a baseline model VQREC pq.py I met munmap_chunk(): invalid pointer \n segmentation fault (core dump), when feat_size is bigger than 1024, but when feat_size = 768 its ok. I minimized the code below, so it can help with Reproduction the issue. (I am new to faiss, but I would like know how to fix it, thanks)

# -*- coding: utf-8 -*-
import numpy as np
import faiss
res = faiss.StandardGpuResources()
feat_size = 1024 # segment fault core dump
feat_size = 768 # ok 

index_cpu = faiss.index_factory(feat_size, "OPQ32,IVF1,PQ8x8", faiss.METRIC_INNER_PRODUCT)
index_cpu.verbose = True

filtered_feat = np.random.randn(1000, feat_size).astype('float32')

index_cpu.train(filtered_feat)

print('Training completed.')

Platform

OS: Ubuntu 20.04 Faiss version: faiss 1.9.0 Installed from: anaconda Faiss compilation options:

Running on:

Interface:

Reproduction instructions

Just run the code, with different feat_size.

cywuuuu commented 2 days ago

My RAM is 500GB, and i have not observe the surge of ram usage when running the code (or maybe everything happened too fast?), If anyone could help me understand the exact cause, I would greatly appreciate it.

junjieqi commented 1 day ago

hi @cywuuuu, I just tried to re-run the code you provided and use feat_size = 1024. The code is running fine. Probably you want to isolate the issue from your code to see where the seg_fault happened

cywuuuu commented 1 day ago

Well, it is quite strange because I do have that issue when rerunning the code, I give my detail as below(The segment fault core dump is described in Chinese 已放弃 (核心已转储), sorry for that because i am using Chinese Ver of Ubuntu) image image

And the following is the package I am using: image

I am curious why. Hopefully you can help me out, I would greatly appreciate it,thanks @junjieqi

junjieqi commented 3 hours ago

@cywuuuu thanks for providing additional information. I'm wondering why you are using faiss-gpu. Since I saw you initialize res = faiss.StandardGpuResources(), but that parameter never got used. Do you want to remove that one first and re-run the code?