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

Python bindings cannot find msvcp140.dll - is there something I need to install? #2918

Closed
LY1806620741 opened this issue Aug 28, 2024 · 7 comments
Labels
bindings gpt4all-binding issues python-bindings gpt4all-bindings Python specific issues question general questions

Comments

@LY1806620741
Copy link

LY1806620741 commented Aug 28, 2024

Bug Report

python model gpt4all can't load llmdel.dll on win11 because no msvcp140.dll

Example Code

Steps to Reproduce

  1. install gpt4all application gpt4all-installer-win64-v3.2.1
  2. install python-3.12.5-amd64
  3. install pip install gpt4all
  4. run example
from gpt4all import GPT4All
model = GPT4All("Meta-Llama-3-8B-Instruct.Q4_0.gguf") # downloads / loads a 4.66GB LLM
with model.chat_session():
    print(model.generate("How can I run LLMs efficiently on my laptop?", max_tokens=1024))

then error was happen:

PS C:\Users\Administrator\Desktop\local-Thinkpad-20UAS29100\python> python .\test.py
Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\gpt4all\_pyllmodel.py", line 81, in load_llmodel_library
    lib = ctypes.CDLL(str(MODEL_LIB_PATH / f"libllmodel.{ext}"))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\ctypes\__init__.py", line 379, in __init__
    self._handle = _dlopen(self._name, mode)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: Could not find module 'C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\gpt4all\llmodel_DO_NOT_MODIFY\build\libllmodel.dll' (or one of its dependencies). Try using the full path with constructor syntax.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Administrator\Desktop\local-Thinkpad-20UAS29100\python\test.py", line 1, in <module>
    from gpt4all import GPT4All
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\gpt4all\__init__.py", line 1, in <module>
    from .gpt4all import CancellationError as CancellationError, Embed4All as Embed4All, GPT4All as GPT4All
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\gpt4all\gpt4all.py", line 23, in <module>
    from ._pyllmodel import (CancellationError as CancellationError, EmbCancelCallbackType, EmbedResult as EmbedResult,
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\gpt4all\_pyllmodel.py", line 91, in <module>
    llmodel = load_llmodel_library()
              ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\gpt4all\_pyllmodel.py", line 86, in load_llmodel_library
    lib = ctypes.CDLL(str(MODEL_LIB_PATH / "llmodel.dll"))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\ctypes\__init__.py", line 379, in __init__
    self._handle = _dlopen(self._name, mode)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: Could not find module 'C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\gpt4all\llmodel_DO_NOT_MODIFY\build\llmodel.dll' (or one of its dependencies). Try using the full path with constructor syntax.

how to fix

I found llmodel.dll exist. But It depends on msvcp140.dll. From Microsoft Visual C++ Redistributable Packages for Visual Studio 2015.

It loads my JetBrains Intellij IDEA's dynamic library msvcp140.dll (because the IDEA bin path is in system environment). But they do not match.

I copy msvcp140.dll and msvcp140_1.dll from gpt4all application's lib path C:\Users\Administrator\gpt4all\bin to gpt4all python module's lib path C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\gpt4all\llmodel_DO_NOT_MODIFY\build. then fix.

Expected Behavior

Expected the module can used or report what i need to do.

Your Environment

  • Bindings version (e.g. "Version" from pip show gpt4all): 2.8.2
  • Operating System(systeminfo): Microsoft Windows 11 professional 10.0.22631 Build 22631
  • Chat model used (if applicable): no
@LY1806620741 LY1806620741 added bindings gpt4all-binding issues bug-unconfirmed labels Aug 28, 2024
@LY1806620741
Copy link
Author

I've fixed the issue and am reporting it here in hopes of helping others or improving the usability of the software.

@cebtenzzre
Copy link
Member

If you remove the DLLs you copied into the llmodel_DO_NOT_MODIFY directory, and you install https://aka.ms/vs/17/release/vc_redist.x64.exe, does GPT4All import successfully?

@cebtenzzre cebtenzzre added the need-info Further information from issue author is requested label Aug 28, 2024
@cebtenzzre cebtenzzre reopened this Aug 28, 2024
@LY1806620741
Copy link
Author

LY1806620741 commented Aug 29, 2024

If you remove the DLLs you copied into the llmodel_DO_NOT_MODIFY directory, and you install https://aka.ms/vs/17/release/vc_redist.x64.exe, does GPT4All import successfully?

success.

when I remove copy file, import error again. then I download and install your vc2015 runtime, it was ok.
image

@LY1806620741

This comment was marked as duplicate.

@cebtenzzre
Copy link
Member

when I remove copy file, import error again. then I download and install your vc2015 runtime, it was ok.

Thanks for confirming. That means the warning I'm adding in #2920 likely would have been helpful in your case, and should help other users in the future.

@cebtenzzre cebtenzzre added question general questions python-bindings gpt4all-bindings Python specific issues and removed need-info Further information from issue author is requested bug-unconfirmed labels Aug 29, 2024
@cebtenzzre cebtenzzre changed the title llmodel.dll' (or one of its dependencies). Try using the full path with constructor syntax. Python bindings cannot find msvcp140.dll - is there something I need to install? Aug 29, 2024
@cebtenzzre
Copy link
Member

The PR was merged and will be included in the next release of the python bindings.

@LY1806620741
Copy link
Author

Thank you for your sense of responsibility. Happy for other users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bindings gpt4all-binding issues python-bindings gpt4all-bindings Python specific issues question general questions
Projects
None yet
Development

No branches or pull requests

4 participants
@cebtenzzre @LY1806620741 and others