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

GPT4All python binding on Intel Mac is easy to fix #3187

Open
MarcusUppmax opened this issue Nov 14, 2024 · 3 comments
Open

GPT4All python binding on Intel Mac is easy to fix #3187

MarcusUppmax opened this issue Nov 14, 2024 · 3 comments
Labels
bindings gpt4all-binding issues bug-unconfirmed

Comments

@MarcusUppmax
Copy link

Bug Report

The python module says that running GPT4All on an Apple Silicon mac through Rosetta isn't supported. I was trying to run it on my Intel mac, and was running into a crash when importing the module on line 30-something of _pyllmodel.py. Since I wasn't using Rosetta, and that line was just supposed to detect it (I think?), I commented it out and everything now works great. I didn't make a PR because I'm not at all sure what you're even doing with that code.

Steps to Reproduce

  1. Have a MacBook Pro from 2018
  2. pip install gpt4all
  3. in python, import gpt4all

Expected Behavior

I expect gpt4all to be loaded.

Your Environment

  • Bindings version (e.g. "Version" from pip show gpt4all): 2.8.2
  • Operating System: MacOS 12.something and MacOS 15.1
@MarcusUppmax MarcusUppmax added bindings gpt4all-binding issues bug-unconfirmed labels Nov 14, 2024
@charlod
Copy link

charlod commented Dec 12, 2024

I’m encountering the same issue on a Mac Intel. Looking at the source code the issue seems to be caused by the check_rosetta function in_pyllmodel.py lines 42-49 in the main branch as mentioned above:

# Detect Rosetta 2
@_operator_call
def check_rosetta() -> None:
    if platform.system() == "Darwin" and platform.processor() == "i386":
        p = subprocess.run("sysctl -n sysctl.proc_translated".split(), capture_output=True, text=True)
        if p.returncode == 0 and p.stdout.strip() == "1":
            raise RuntimeError(textwrap.dedent("""\
                Running GPT4All under Rosetta is not supported due to CPU feature requirements.
                Please install GPT4All in an environment that uses a native ARM64 Python interpreter.
            """).strip())

Followed the same steps to reproduce and got:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/abc/lib/python3.11/site-packages/gpt4all/__init__.py", line 1, in <module>
    from .gpt4all import CancellationError as CancellationError, Embed4All as Embed4All, GPT4All as GPT4All
  File ""/Users/abc/lib/python3.11/site-packages/gpt4all/gpt4all.py", line 23, in <module>
    from ._pyllmodel import (CancellationError as CancellationError, EmbCancelCallbackType, EmbedResult as EmbedResult,
  File ""/Users/abc/python3.11/site-packages/gpt4all/_pyllmodel.py", line 34, in <module>
    if subprocess.run(
       ^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/[email protected]/3.11.9/Frameworks/Python.framework/Versions/3.11/lib/python3.11/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['sysctl', '-n', 'sysctl.proc_translated']' returned non-zero exit status 1.

When sysctl.proc_translated key doesn’t exist (which is the case for Intel Macs as it doesn't support Rosetta 2), the subprocess.run call fails with a CalledProcessError.

@yalmaz-ali
Copy link

Same issue when I try:

from gpt4all import GPT4All

@kasiperumal
Copy link

Same issue with macOS 15.3,

from gpt4all import GPT4All as GPT4AllModel

subprocess.CalledProcessError: Command '['sysctl', '-n', 'sysctl.proc_translated']' returned non-zero exit status 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bindings gpt4all-binding issues bug-unconfirmed
Projects
None yet
Development

No branches or pull requests

4 participants