Closed ssnl closed 6 years ago
I am wondering if the /tmp/adverarial_dataset
folder actually gets created somewhere? Does the error go away when you run mkdir /tmp/adverarial_dataset
right before running the demo?
The folder does seem to exist after running the script. I also tried deleting it, mkdir a new one, and then run the script. But it still segfaults. So far this has been reproduced on two Ubuntu 16 machines.
I think I found the reason.
In index_patches.py
, quantizer
and pca_matrix
are instantiated and used to create faiss_index
inside a local function. But then they get freed by Swig library when they go out of scope. These instances are later referenced inside write_index
and cause segfault.
To make the code work, simply returning references of quantizer
and pca_matrix
at the end of index_patches
to prevent garbage collection is sufficient, but I think more fundamentally something should be fixed on Swig or faiss side. I attached the backtrace of deallocation.
Thanks @taesung89 , Yes, you are absolutely right, I was also surprised by this. However, it is not happening with all setups, probably because of gcc versions. I am able to reproduce it and will push the fix very soon.
Fix is being pushed, it should be there in a few minutes.
faiss with openblas on Ubuntu 16. From gdb it seems to segfault on a dynamic cast.
gdb outputs:
cc @taesung89