Apparently cpu_cores library does not work on Windows
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import json
|
||||
import multiprocessing
|
||||
import os
|
||||
import platform
|
||||
import subprocess
|
||||
import sys
|
||||
@@ -58,6 +59,34 @@ def getBlenderVersion(ctx):
|
||||
return info
|
||||
|
||||
|
||||
def _getWmicCPUInfo(value):
|
||||
cmd = ("wmic", "cpu", "get", value, "/value")
|
||||
wmic_output = subprocess.check_output(cmd)
|
||||
return wmic_output.strip().decode()
|
||||
|
||||
|
||||
def _getCPUTopologyInformation():
|
||||
"""
|
||||
Get topology information (number of sockets, physical and logical threads)
|
||||
of the system CPUs.
|
||||
"""
|
||||
import multiprocessing
|
||||
topology_info = {}
|
||||
topology_info["num_logical_threads"] = multiprocessing.cpu_count()
|
||||
if not sys.platform.startswith('win'):
|
||||
cores_info = cpu_cores.CPUCoresCounter.factory()
|
||||
topology_info["num_sockets"] = \
|
||||
cores_info.get_physical_processors_count()
|
||||
topology_info["num_physical_cores"] = \
|
||||
cores_info.get_physical_cores_count()
|
||||
else:
|
||||
num_cores = _getWmicCPUInfo("NumberOfCores").split("=")[1]
|
||||
# TODO(sergey): Needs implementation.
|
||||
topology_info["num_sockets"] = 1
|
||||
topology_info["num_physical_cores"] = num_cores
|
||||
return topology_info
|
||||
|
||||
|
||||
def gatherSystemInfo(ctx):
|
||||
system_info = {}
|
||||
system_info['bitness'] = platform.architecture()[0]
|
||||
@@ -70,11 +99,10 @@ def gatherSystemInfo(ctx):
|
||||
# system_info['libc_version'] = "-".join(platform.libc_ver())
|
||||
# TODO(sergey): Make this to work on Windows and macOS
|
||||
cpu_info = cpuinfo.get_cpu_info()
|
||||
cores_info = cpu_cores.CPUCoresCounter.factory()
|
||||
cpu_topology = _getCPUTopologyInformation()
|
||||
system_info['cpu_brand'] = cpu_info['brand']
|
||||
system_info["num_cpu_cores"] = cores_info.get_physical_cores_count()
|
||||
system_info["num_cpu_threads"] = multiprocessing.cpu_count()
|
||||
system_info["num_cpu_sockets"] = cores_info.get_physical_processors_count()
|
||||
system_info["num_cpu_threads"] = cpu_topology['num_logical_threads']
|
||||
system_info["num_cpu_sockets"] = cpu_topology['num_sockets']
|
||||
system_info["num_cpu_cores"] = cpu_topology['num_physical_cores']
|
||||
system_info['devices'] = _getBlenderDeviceInfo(ctx)
|
||||
# TODO(sergey): query number of CPUs and threads.
|
||||
return system_info
|
||||
|
Reference in New Issue
Block a user