Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions nlu/utils/environment/env_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import os, sys
import logging
import os
import platform
import subprocess
import sys

logger = logging.getLogger('nlu')

Expand Down Expand Up @@ -157,4 +160,26 @@ def try_import_spark_nlp():
except:
print("You need Spark NLP to run NLU. run pip install spark-nlp")
return False
return True
return True


def is_m1():
"""Checks whether the current processor is an Apple M1 chip."""
platform_info = platform.uname()
if platform_info.system == "Darwin" and platform_info.machine == "arm64":
sys_info_query = "sysctl -n machdep.cpu.brand_string"
result = subprocess.run(sys_info_query.split(), capture_output=True)
cpu = result.stdout.decode().strip()
if cpu == "Apple M1":
return True
else:
logger.info(
(
"Currently, only the standard M1 processor has experimental "
"support.\nOther derivations like M1 Pro/Max/Ultra will be "
"supported in the future."
)
)
return False
else:
return False