Fix CPU count parameter for cmft
This commit is contained in:
parent
b579c8a15d
commit
c40fd26c20
|
@ -130,7 +130,7 @@ def get_fp():
|
||||||
def get_fp_build():
|
def get_fp_build():
|
||||||
return os.path.join(get_fp(), build_dir())
|
return os.path.join(get_fp(), build_dir())
|
||||||
|
|
||||||
def get_os():
|
def get_os() -> str:
|
||||||
s = platform.system()
|
s = platform.system()
|
||||||
if s == 'Windows':
|
if s == 'Windows':
|
||||||
return 'win'
|
return 'win'
|
||||||
|
@ -1111,6 +1111,42 @@ def get_list_installed_vs_path() -> []:
|
||||||
err = 'File "'+ path_file +'" not found.'
|
err = 'File "'+ path_file +'" not found.'
|
||||||
return items, err
|
return items, err
|
||||||
|
|
||||||
|
|
||||||
|
def cpu_count(*, physical_only=False) -> Optional[int]:
|
||||||
|
"""Returns the number of logical (default) or physical CPUs.
|
||||||
|
The result can be `None` if `os.cpu_count()` was not able to get the
|
||||||
|
correct count of logical CPUs.
|
||||||
|
"""
|
||||||
|
if not physical_only:
|
||||||
|
return os.cpu_count()
|
||||||
|
|
||||||
|
_os = get_os()
|
||||||
|
try:
|
||||||
|
if _os == 'win':
|
||||||
|
result = subprocess.check_output(['wmic', 'cpu', 'get', 'NumberOfCores'])
|
||||||
|
result = result.decode('utf-8').splitlines()
|
||||||
|
result = int(result[2])
|
||||||
|
if result > 0:
|
||||||
|
return result
|
||||||
|
|
||||||
|
elif _os == 'linux':
|
||||||
|
result = subprocess.check_output("grep -P '^core id' /proc/cpuinfo | sort -u | wc -l", shell=True)
|
||||||
|
result = result.decode('utf-8').splitlines()
|
||||||
|
result = int(result[0])
|
||||||
|
if result > 0:
|
||||||
|
return result
|
||||||
|
|
||||||
|
# macOS
|
||||||
|
else:
|
||||||
|
return int(subprocess.check_output(['sysctl', '-n', 'hw.physicalcpu']))
|
||||||
|
except subprocess.CalledProcessError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Last resort even though it can be wrong
|
||||||
|
log.warn("Could not retrieve count of physical CPUs, using logical CPU count instead.")
|
||||||
|
return os.cpu_count()
|
||||||
|
|
||||||
|
|
||||||
def register(local_sdk=False):
|
def register(local_sdk=False):
|
||||||
global use_local_sdk
|
global use_local_sdk
|
||||||
use_local_sdk = local_sdk
|
use_local_sdk = local_sdk
|
||||||
|
|
|
@ -187,7 +187,10 @@ def write_probes(image_filepath: str, disable_hdr: bool, cached_num_mips: int, a
|
||||||
|
|
||||||
wrd = bpy.data.worlds['Arm']
|
wrd = bpy.data.worlds['Arm']
|
||||||
use_opencl = 'true'
|
use_opencl = 'true'
|
||||||
cpu_count = multiprocessing.cpu_count()
|
|
||||||
|
# cmft doesn't work correctly when passing the number of logical
|
||||||
|
# CPUs if there are more logical than physical CPUs on a machine
|
||||||
|
cpu_count = arm.utils.cpu_count(physical_only=True)
|
||||||
|
|
||||||
if arm.utils.get_os() == 'win':
|
if arm.utils.get_os() == 'win':
|
||||||
cmd = [
|
cmd = [
|
||||||
|
|
Loading…
Reference in a new issue