From 19218550df8edb18c6355bdfbd7317145696c0e2 Mon Sep 17 00:00:00 2001 From: Luke Nezda Date: Thu, 28 Dec 2023 08:26:14 -0600 Subject: [PATCH 1/3] make get_number_of_sockets and CpuInfo.get_number_of_sockets work on intel mac Signed-off-by: Luke Nezda --- neural_compressor/utils/utility.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/neural_compressor/utils/utility.py b/neural_compressor/utils/utility.py index 1777d52f6f5..f07e18ae014 100644 --- a/neural_compressor/utils/utility.py +++ b/neural_compressor/utils/utility.py @@ -276,6 +276,8 @@ def get_number_of_sockets(self) -> int: cmd = "lscpu | grep 'Socket(s)' | cut -d ':' -f 2" if psutil.WINDOWS: cmd = r'wmic cpu get DeviceID | C:\Windows\System32\find.exe /C "CPU"' + elif psutil.MACOS: + cmd = "sysctl -n machdep.cpu.core_count" with subprocess.Popen( args=cmd, @@ -918,6 +920,8 @@ def get_number_of_sockets() -> int: cmd = "lscpu | grep 'Socket(s)' | cut -d ':' -f 2" if sys.platform == "win32": cmd = 'wmic cpu get DeviceID | find /c "CPU"' + elif sys.platform == "darwin": + cmd = 'sysctl -n machdep.cpu.core_count' proc = subprocess.Popen( args=cmd, From ef924e6c37dffbd145c96498f1617877b459e399 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 28 Dec 2023 16:33:00 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- neural_compressor/utils/utility.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neural_compressor/utils/utility.py b/neural_compressor/utils/utility.py index f07e18ae014..1ce0019621d 100644 --- a/neural_compressor/utils/utility.py +++ b/neural_compressor/utils/utility.py @@ -921,7 +921,7 @@ def get_number_of_sockets() -> int: if sys.platform == "win32": cmd = 'wmic cpu get DeviceID | find /c "CPU"' elif sys.platform == "darwin": - cmd = 'sysctl -n machdep.cpu.core_count' + cmd = "sysctl -n machdep.cpu.core_count" proc = subprocess.Popen( args=cmd, From 54149a560157d3ce939361b0b7b946dc63ca4a10 Mon Sep 17 00:00:00 2001 From: Luke Nezda Date: Thu, 28 Dec 2023 08:26:14 -0600 Subject: [PATCH 3/3] make get_number_of_sockets and CpuInfo.get_number_of_sockets work on intel mac Signed-off-by: Luke Nezda --- neural_compressor/utils/utility.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/neural_compressor/utils/utility.py b/neural_compressor/utils/utility.py index 2921dcc8470..36d980eb16d 100644 --- a/neural_compressor/utils/utility.py +++ b/neural_compressor/utils/utility.py @@ -276,7 +276,7 @@ def get_number_of_sockets(self) -> int: cmd = "cat /proc/cpuinfo | grep 'physical id' | sort -u | wc -l" if psutil.WINDOWS: cmd = r'wmic cpu get DeviceID | C:\Windows\System32\find.exe /C "CPU"' - elif psutil.MACOS: + elif psutil.MACOS: # pragma: no cover cmd = "sysctl -n machdep.cpu.core_count" with subprocess.Popen( @@ -920,7 +920,7 @@ def get_number_of_sockets() -> int: cmd = "cat /proc/cpuinfo | grep 'physical id' | sort -u | wc -l" if sys.platform == "win32": cmd = 'wmic cpu get DeviceID | find /c "CPU"' - elif sys.platform == "darwin": + elif sys.platform == "darwin": # pragma: no cover cmd = "sysctl -n machdep.cpu.core_count" proc = subprocess.Popen(