nomic-ai / gpt4all

GPT4All: Run Local LLMs on Any Device. Open-source and available for commercial use.
https://nomic.ai/gpt4all
MIT License
70.72k stars 7.71k forks source link

Error when import the gpt4all library #2862

Closed samyon7 closed 3 months ago

samyon7 commented 3 months ago

Error when try to run in google colabs

I tried to run in Google Colab using T4 GPU but getting error

Traceback (most recent call last):

  File "/usr/local/lib/python3.10/dist-packages/IPython/core/interactiveshell.py", line 3553, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)

  File "<ipython-input-3-0a88d3473920>", line 1, in <cell line: 1>
    from gpt4all import GPT4All

  File "/usr/local/lib/python3.10/dist-packages/gpt4all/__init__.py", line 1, in <module>
    from .gpt4all import CancellationError as CancellationError, Embed4All as Embed4All, GPT4All as GPT4All

  File "/usr/local/lib/python3.10/dist-packages/gpt4all/gpt4all.py", line 23, in <module>
    from ._pyllmodel import (CancellationError as CancellationError, EmbCancelCallbackType, EmbedResult as EmbedResult,

  File "/usr/local/lib/python3.10/dist-packages/gpt4all/_pyllmodel.py", line 48
    cudalib   = fr"bin\cudart64_{rtver.replace(".", "")}.dll"
                                                ^
SyntaxError: f-string: unmatched '('

Can you please help me and tell me how to fix it? Thanks for the short instructions! Best regards

Environment :

cosmic-snow commented 3 months ago

I see the problem, that's a bug.

You can open the mentioned _pyllmodel.py on line 48 and replace:

cudalib   = fr"bin\cudart64_{rtver.replace(".", "")}.dll"

with:

cudalib   = fr"bin\cudart64_{rtver.replace('.', '')}.dll"

That should fix it. Note the single quotes.

cosmic-snow commented 3 months ago

Although other than that, I'm not sure how you landed on that specific line. That's code which is meant to run on a Windows system, but your paths indicate you're running this on *nix.

See here: https://github.com/nomic-ai/gpt4all/blob/3386ac6331ee79af776a27af4a3b80774ff84d58/gpt4all-bindings/python/gpt4all/_pyllmodel.py#L43-L49

What do you get when you write:

>>> import platform
>>> print(platform.system())

Edit: Never mind, this did not actually run, so this should be fixed.