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

[BUG] Problem installing faiss-cpu when Python 3.12 is used #2119

Open
umago opened this issue Jan 8, 2025 · 0 comments
Open

[BUG] Problem installing faiss-cpu when Python 3.12 is used #2119

umago opened this issue Jan 8, 2025 · 0 comments

Comments

@umago
Copy link

umago commented Jan 8, 2025

Bug Description

Installing the faiss-cpu dependency fails when Python 3.12 is used with the following error:

pdm.termui: faiss/faiss/python/swigfaiss.i:622: Error: Unable to find 'faiss/impl/AuxIndexStructures.h'
pdm.termui: faiss/faiss/python/swigfaiss.i:623: Error: Unable to find 'faiss/impl/IDSelector.h'
pdm.termui: faiss/faiss/python/swigfaiss.i:625: Error: Unable to find 'faiss/IndexIDMap.h'
pdm.termui: faiss/faiss/python/swigfaiss.i:632: Error: Unable to find 'faiss/utils/approx_topk/mode.h'
pdm.termui: faiss/faiss/python/swigfaiss.i:897: Error: Unable to find 'faiss/index_io.h'
pdm.termui: faiss/faiss/python/swigfaiss.i:898: Error: Unable to find 'faiss/clone_index.h'
pdm.termui: faiss/faiss/python/swigfaiss.i:902: Error: Unable to find 'faiss/AutoTune.h'
pdm.termui: faiss/faiss/python/swigfaiss.i:903: Error: Unable to find 'faiss/index_factory.h'
pdm.termui: faiss/faiss/python/swigfaiss.i:904: Error: Unable to find 'faiss/MatrixStats.h'
pdm.termui: error: command '/usr/bin/swig' failed with exit code 1
  ✖ Install faiss-cpu 1.9.0.post1 failed

See full logs at: install-tools-output.txt

I was able to start the service without that dependency but it would error out as below when the RAG was configured:

2025-01-07 14:02:20,762 [ols.src.auth.auth:auth.py:34] INFO: Authentication retrieval for module noop and virtual path /ols-access
2025-01-07 14:02:20,765 [ols.src.auth.auth:auth.py:34] INFO: Authentication retrieval for module noop and virtual path /ols-access
INFO:     Started server process [810019]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://0.0.0.0:8080 (Press CTRL+C to quit)
2025-01-07 14:02:23,810 [ols.src.rag_index.index_loader:index_loader.py:73] INFO: Setting up settings for index load...
LLM is explicitly disabled. Using MockLLM.
2025-01-07 14:02:24,090 [ols.src.rag_index.index_loader:index_loader.py:76] INFO: Setting up storage context for index load...
2025-01-07 14:02:24,091 [ols.src.rag_index.index_loader:index_loader.py:97] ERROR: Error loading vector index:
No module named 'faiss'
Traceback (most recent call last):
  File "/home/lucas/ols/lightspeed-service/ols/src/rag_index/index_loader.py", line 89, in _load_index
    self._set_context()
  File "/home/lucas/ols/lightspeed-service/ols/src/rag_index/index_loader.py", line 79, in _set_context
    vector_store=FaissVectorStore.from_persist_dir(self._index_path),
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lucas/ols/lightspeed-service/.venv/lib/python3.12/site-packages/llama_index/vector_stores/faiss/base.py", line 94, in from_persist_dir
    return cls.from_persist_path(persist_path=persist_path, fs=None)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lucas/ols/lightspeed-service/.venv/lib/python3.12/site-packages/llama_index/vector_stores/faiss/base.py", line 102, in from_persist_path
    import faiss
ModuleNotFoundError: No module named 'faiss'
2025-01-07 14:02:24,092 [ols.src.rag_index.index_loader:index_loader.py:103] WARNING: Proceeding without RAG content. Either there is an error or required parameters are not
 set.

Searching on the web I came across the following comment saying that the issue is due to Python 3.12: facebookresearch/faiss#1589 (comment)

I then reverted the following commit and it worked for me: 07d4391

My OS is RHEL 9.4.

Output of OLS version

OLS Version: It was main branch latest commit 90e13d8

To Reproduce

On a RHEL 9.4 machine

  1. Clone the repository
git clone https://github.com/openshift/lightspeed-service
cd lightspeed-service
  1. Run "make install-tools"

After some time you should be able to see the error mid-installation

Expected behavior

Dependencies to be installed correctly

Additional information

As said in the bug description, reverting the commit 07d4391 will cause pdm to use the Python version 3.11 and everything worked for me after that.

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

No branches or pull requests

1 participant