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

Importing faiss has side effect causing segfault #2463

Closed
2 of 4 tasks
lg8080 opened this issue Sep 9, 2022 · 4 comments
Closed
2 of 4 tasks

Importing faiss has side effect causing segfault #2463

lg8080 opened this issue Sep 9, 2022 · 4 comments
Labels

Comments

@lg8080
Copy link

lg8080 commented Sep 9, 2022

Summary

Importing faiss has some undocumented side effects that are indirectly causing a crash on Mac.

Platform

OS: macOS 11.6.4

Faiss version: 1.7.2

Installed from: pip

Running on:

  • CPU
  • GPU

Interface:

  • C++
  • Python

Reproduction instructions

This snippet results in a segmentation fault on the last line on Mac:

import faiss
import implicit, scipy
implicit.als.AlternatingLeastSquares().fit(scipy.sparse.csr_matrix(0.5))

The code runs fine if I remove the first line.

System: macOS 11.6.4, 2.3 GHz Quad-Core Intel Core i7, CPython 3.10.2 (but the crash also happens on 3.8.12). Faiss installed from faiss_cpu-1.7.2-cp310-cp310-macosx_10_9_x86_64.whl with pip install faiss-cpu.

List of packages installed:

faiss-cpu==1.7.2
implicit==0.6.1
numpy==1.23.2
scipy==1.9.1
tqdm==4.64.1

Questions

  1. What are the side effects of running import faiss?
  2. Is there a way to create a version of faiss-cpu that doesn't have these side effects?
@benfred
Copy link
Contributor

benfred commented Sep 10, 2022

See also benfred/implicit#613 (comment)

@wx257osn2
Copy link
Contributor

wx257osn2 commented Sep 12, 2022

@lg8080 Based on benfred/implicit#613 (comment), it seems that it should work correctly what faiss built with libomp.dylib from source, instead of faiss-cpu on PyPI which linked to libomp.a .
(Or, implicit built with libomp.a should also work together with faiss-cpu on PyPI.)
Would you try building faiss (or implicit) from source?

NOTE: faiss-{c,g}pu on PyPI are NOT official packages (that are maintained on kyamagu/faiss-wheels, NOT by faiss maintainers), and this problem is specific to faiss-wheels . So, this issue is difficult to deal with for faiss maintainers.

@mdouze
Copy link
Contributor

mdouze commented Sep 12, 2022

pip is not a supported way of installing Faiss.
It causes a lot of problems like this, especially on Macs, so please install via conda.

@mdouze mdouze added the install label Sep 13, 2022
@lg8080
Copy link
Author

lg8080 commented Sep 15, 2022

Thank you all for the answers! Really appreciate it. I will try using conda.

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

No branches or pull requests

4 participants