private-gpt
private-gpt copied to clipboard
Can anyone help on this hnswlib issue? Three different people have mentioned this. I am number four. Thanks.
Discussed in https://github.com/imartinez/privateGPT/discussions/361
Originally posted by pdesainteagathe May 22, 2023 when launching python ingest.py
I get
import hnswlib
ImportError: /home/pdsagathe/repo/local_llm/privateGPT/venv/lib/python3.9/site-packages/hnswlib.cpython-39-x86_64-linux-gnu.so: undefined symbol: _ZNSt15__exception_ptr13exception_ptr10_M_releaseEv
```</div>
Yes, I had to face a similar problem with the hnswlib yesterday.
Im my case, the error was due to the absence of Microsoft Visual C++ 14.0 or a later version on my machine. The hnswlib package requires a C++ compiler to build some of its components, and this compiler was not present on my system.
To resolve this issue, I had to install Microsoft's C++ build tools. The link to obtain it was provided in my error message: https://visualstudio.microsoft.com/visual-cpp-build-tools/ From there, it was easy. Once on the page, download and install the Visual Studio 2019 build tools. Make sure to select "C++ build tools" during installation and include the latest versions of MSVCv142 - VS 2019 C++ x64/x86 build tools (v14.28) and Windows 10 SDK. After installation, restart the computer. Then, reinstall the hnswlib package using pip.
In your case, here is my analysis and suggestions... from chatgpt
The error you encounter is usually caused by an incompatibility between the versions of the C++ Standard Library used to compile Python and the libraryhnswlib. The error message indicates that a symbol (i.e. function or variable) called is missing_ZNSt15__exception_ptr13exception_ptr10_M_releaseEv in the libraryhnswlib.cpython-39-x86_64-linux-gnu.so. This symbol is probably provided by the C++ Standard Library, so if the versions don't match, you may get this kind of error. Here are some suggestions for solving this problem: Reinstall hnswlib: Try uninstalling and reinstallinghnswlib with pee. This can sometimes fix the problem if the installed version is corrupted or misconfigured. Update your C++ compiler: Make sure you are using a recent version of the C++ compiler. If you are using gcc, you can check your version withgcc --version and update if necessary. Recompile Python: If you compiled Python yourself, be sure to use the same C++ compiler and options for Python andhnswlib. You may need to recompile Python with a different version of the C++ compiler. Use a virtual environment: If you're not already using a Python virtual environment, try creating one withvenv orconda, then installhnswlib in this environment. This can help isolate dependency issues. If none of these suggestions solve the problem, I recommend that you contact the developers ofhnswlib to get help. It is possible that there is a bug in the library that needs fixing.
@Orrouk that looks like a ms windows only installer, not sure how this would work on other operating systems.
My anaconda python 3.10.9 does not have this problem... so... that could be a workaround?
I also encountered this problem and then went to the hnswlib project, at the following address, which eventually solved the problem: https://github.com/nmslib/hnswlib
apt-get install -y python-setuptools python-pip git clone https://github.com/nmslib/hnswlib.git cd hnswlib pip install .
Unfortunately that still doesn't seem to fix it on macOS as it's building hnswlib that's the problem.
git clone https://github.com/nmslib/hnswlib.git
cd hnswlib
pip install .
....
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/unique_ptr.h:602:12: error: unknown type name 'nullptr_t'
operator==(nullptr_t, const unique_ptr<_T1, _D1>& __x) _NOEXCEPT
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/unique_ptr.h:610:45: error: unknown type name 'nullptr_t'
operator!=(const unique_ptr<_T1, _D1>& __x, nullptr_t) _NOEXCEPT
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
error: command '/usr/bin/clang' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for hnswlib
Failed to build hnswlib
ERROR: Could not build wheels for hnswlib, which is required to install pyproject.toml-based projects
I am having the same error on Ubuntu :(
The suggestion from the docs have solved it for me on Mac: https://github.com/imartinez/privateGPT#mac-running-intel
In windows I didn't find any issue as long as using windows 10+ and updated windows with python 3.10. All pip install worked flawlessly. https://github.com/h2oai/h2ogpt#windows-1011 . The same kind of instructions should work for privateGPT.
The suggestion from the docs have solved it for me on Mac: https://github.com/imartinez/privateGPT#mac-running-intel
And this is why you should read the whole readme, thanks!
Yeah that part of the readme didn't work on any of the machines I tried.
However - completely uninstalling Xcode and reinstalling it did.
On a Mac M1, I was getting this error message when attempting to run ingest.py
ImportError: dlopen(/Users/.../lib/python3.10/site-packages/hnswlib.cpython-310-darwin.so, 0x0002): tried: '/Users/.../lib/python3.10/site-packages/hnswlib.cpython-310-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/.../lib/python3.10/site-packages/hnswlib.cpython-310-darwin.so' (no such file), '/Users/.../lib/python3.10/site-packages/hnswlib.cpython-310-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64'))
This issue at the hnswlib repo helped me resolve the issue:
# 1. Uninstall hnswlib
> pip uninstall hnswlib
# 2. Clear the pip cache
> pip cache purge
# 3. Reinstall with the arm64 architecture
> ARCHFLAGS="-arch arm64" pip install hnswlib
this worked in macos - apparently clang compiler gets disrupted if we have gcc installed/upgraded for golang. Reinstalling Xcodec tools in mac doesnt seem to fix the issue. Instead this can be used as a temp solution
export SYSTEM_VERSION_COMPAT=1
once the env var is set, then proceed to install hnswlib, it worked for me. Detailed explanation below
stack overflow
simply use conda is the solution works for me, on my Windows 10.
conda install hnswlib
This worked for me (M2 Studio Ultra):
> pip uninstall hnswlib
# 2. Clear the pip cache
> pip cache purge
# 3. Reinstall with the arm64 architecture
> ARCHFLAGS="-mcpu=apple-m1" pip install hnswlib