facebookresearch / faiss

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

Fresh Faiss Install does not work #3865

Closed jakubLangr closed 1 month ago

jakubLangr commented 2 months ago

Summary

Install does not work despite multiple install methods, fresh conda reinstall, multiple python environments

Platform

Mac OS.X Ventura 13.5.1 Python 3.10 (newer versions did not work)

OS:

Faiss version:

Installed from: Conda Fresh Reinstall

conda install -c conda-forge faiss-cpu -f

WARNING: The --force flag will be removed in a future conda release.
         See 'conda install --help' for details about the --force-reinstall
         and --clobber flags.

Collecting package metadata (current_repodata.json): \ WARNING conda.models.version:get_matcher(535): Using .* with relational operator is superfluous and deprecated and will be removed in a future version of conda. Your spec was 1.7.1.*, but conda is ignoring the .* and treating it as 1.7.1
done
Solving environment: done

==> WARNING: A newer version of conda exists. <==
  current version: 4.12.0
  latest version: 24.7.1

Please update conda by running

    $ conda update -n base -c defaults conda

## Package Plan ##

  environment location: /Users/jlangr/opt/anaconda3/envs/b310

  added / updated specs:
    - faiss-cpu

Proceed ([y]/n)?

Preparing transaction: done
Verifying transaction: done
Executing transaction: done

Faiss compilation options:

Running on:

Interface:

Reproduction instructions

python
Python 3.10.14 (main, May  6 2024, 14:47:20) [Clang 14.0.6 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import faiss
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/jlangr/opt/anaconda3/envs/b310/lib/python3.10/site-packages/faiss/__init__.py", line 16, in <module>
    from .loader import *
  File "/Users/jlangr/opt/anaconda3/envs/b310/lib/python3.10/site-packages/faiss/loader.py", line 65, in <module>
    from .swigfaiss import *
  File "/Users/jlangr/opt/anaconda3/envs/b310/lib/python3.10/site-packages/faiss/swigfaiss.py", line 13, in <module>
    from . import _swigfaiss
ImportError: dlopen(/Users/jlangr/opt/anaconda3/envs/b310/lib/python3.10/site-packages/faiss/_swigfaiss.so, 0x0002): Library not loaded: @rpath/libmkl_intel_lp64.1.dylib
  Referenced from: <4A025BD7-6F1F-3CD5-B319-DE475BB38238> /Users/jlangr/opt/anaconda3/envs/b310/lib/libfaiss.dylib
  Reason: tried: '/opt/homebrew/lib/libmkl_intel_lp64.1.dylib' (no such file), '/libmkl_intel_lp64.1.dylib' (no such file), '/Users/jlangr/opt/anaconda3/envs/b310/lib/libmkl_intel_lp64.1.dylib' (no such file), '/Users/jlangr/opt/anaconda3/envs/b310/lib/python3.10/site-packages/faiss/../../../libmkl_intel_lp64.1.dylib' (no such file), '/Users/jlangr/opt/anaconda3/envs/b310/lib/python3.10/site-packages/faiss/../../../libmkl_intel_lp64.1.dylib' (no such file), '/Users/jlangr/opt/anaconda3/envs/b310/bin/../lib/libmkl_intel_lp64.1.dylib' (no such file), '/Users/jlangr/opt/anaconda3/envs/b310/bin/../lib/libmkl_intel_lp64.1.dylib' (no such file), '/usr/local/lib/libmkl_intel_lp64.1.dylib' (no such file), '/usr/lib/libmkl_intel_lp64.1.dylib' (no such file, not in dyld cache)
### Other notes I've tried `brew` install as well as other conda options to no avail. It seems that it always selects the wrong/Intel version but I'm not 100% sure and GPT/Claude etc. were of no help here as they got stuck.
mnorris11 commented 2 months ago

Hi,

Try this:

  1. Download latest miniconda: https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-arm64.sh (or x86_64 depending on your architecture, the installer will give an warning if it is wrong)
  2. conda remove --name faiss_env --all -y in case there's an existing one
  3. conda create -n faiss_env
  4. conda activate faiss_env
  5. conda install -y -q python=3.11 cmake make swig mkl=2023 mkl-devel=2023 numpy scipy pytest gxx_linux-64=11.2 sysroot_linux-64 gflags
  6. which python3 should print somewhere like miniconda3/bin/python3
  7. conda install -c pytorch faiss-cpu=1.8.0

I did a clean install just now and just running import faiss works:

(faiss_env) mnorris@mnorris-mbp:[~]: python3
Python 3.12.5 | packaged by Anaconda, Inc. | (main, Sep 12 2024, 13:22:57) [Clang 14.0.6 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import faiss

I am on Mac OSX Sonoma 14.6.1 though.

github-actions[bot] commented 1 month ago

This issue is stale because it has been open for 7 days with no activity.

github-actions[bot] commented 1 month ago

This issue was closed because it has been inactive for 7 days since being marked as stale.