From 10c3e21147d7e7d9c458f2a2b5fb8e046102024c Mon Sep 17 00:00:00 2001 From: Jared Van Bortel Date: Mon, 5 Aug 2024 13:24:06 -0400 Subject: [PATCH] python: detect Rosetta 2 (#2793) Signed-off-by: Jared Van Bortel --- gpt4all-bindings/python/gpt4all/_pyllmodel.py | 11 +++++++++++ gpt4all-bindings/python/setup.py | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/gpt4all-bindings/python/gpt4all/_pyllmodel.py b/gpt4all-bindings/python/gpt4all/_pyllmodel.py index 284d8ab3..4c52a5b1 100644 --- a/gpt4all-bindings/python/gpt4all/_pyllmodel.py +++ b/gpt4all-bindings/python/gpt4all/_pyllmodel.py @@ -6,6 +6,7 @@ import platform import re import subprocess import sys +import textwrap import threading from enum import Enum from queue import Queue @@ -28,6 +29,16 @@ if TYPE_CHECKING: EmbeddingsType = TypeVar('EmbeddingsType', bound='list[Any]') +# Detect Rosetta 2 +if platform.system() == "Darwin" and platform.processor() == "i386": + if subprocess.run( + "sysctl -n sysctl.proc_translated".split(), check=True, capture_output=True, text=True, + ).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. + """)) + # Find CUDA libraries from the official packages cuda_found = False if platform.system() in ('Linux', 'Windows'): diff --git a/gpt4all-bindings/python/setup.py b/gpt4all-bindings/python/setup.py index 85dbe8ab..4c9c48e1 100644 --- a/gpt4all-bindings/python/setup.py +++ b/gpt4all-bindings/python/setup.py @@ -68,7 +68,7 @@ def get_long_description(): setup( name=package_name, - version="3.0.0", + version="2.8.0.dev0", description="Python bindings for GPT4All", long_description=get_long_description(), long_description_content_type="text/markdown",