Fix libnuma.so does not exsit (#15355)
Signed-off-by: Michael Qiu <qiudayu.qdy@antgroup.com> Co-authored-by: Mike_Qiu <qiudayu.qdy@antgroup.com> Co-authored-by: fzyzcjy <5236035+fzyzcjy@users.noreply.github.com> Co-authored-by: Zhiqiang Xie <xiezhq@stanford.edu>
This commit is contained in:
co-authored by
Mike_Qiu
fzyzcjy
Zhiqiang Xie
parent
48eac1b62d
commit
b79808bee2
@@ -3774,11 +3774,26 @@ def get_device_sm_nvidia_smi():
|
|||||||
return (0, 0) # Default/fallback value
|
return (0, 0) # Default/fallback value
|
||||||
|
|
||||||
|
|
||||||
def numa_bind_to_node(node: int):
|
def get_libnuma():
|
||||||
libnuma = ctypes.CDLL("libnuma.so")
|
libnuma = None
|
||||||
if libnuma.numa_available() < 0:
|
|
||||||
raise SystemError("numa not available on this system")
|
|
||||||
|
|
||||||
|
for libnuma_so in ["libnuma.so", "libnuma.so.1"]:
|
||||||
|
try:
|
||||||
|
libnuma = ctypes.CDLL(libnuma_so)
|
||||||
|
except OSError as e:
|
||||||
|
logger.error(f"{e}")
|
||||||
|
libnuma = None
|
||||||
|
if libnuma is not None:
|
||||||
|
break
|
||||||
|
return libnuma
|
||||||
|
|
||||||
|
|
||||||
|
def numa_bind_to_node(node: int):
|
||||||
|
libnuma = get_libnuma()
|
||||||
|
|
||||||
|
if libnuma is None or libnuma.numa_available() < 0:
|
||||||
|
logger.error("numa not available on this system, skip bind action")
|
||||||
|
else:
|
||||||
libnuma.numa_run_on_node(ctypes.c_int(node))
|
libnuma.numa_run_on_node(ctypes.c_int(node))
|
||||||
libnuma.numa_set_preferred(ctypes.c_int(node))
|
libnuma.numa_set_preferred(ctypes.c_int(node))
|
||||||
|
|
||||||
@@ -4089,13 +4104,13 @@ def get_numa_node_count() -> int:
|
|||||||
Returns:
|
Returns:
|
||||||
int: The number of NUMA nodes.
|
int: The number of NUMA nodes.
|
||||||
"""
|
"""
|
||||||
libnuma = ctypes.CDLL("libnuma.so")
|
libnuma = get_libnuma()
|
||||||
return libnuma.numa_max_node() + 1
|
return libnuma.numa_max_node() + 1
|
||||||
|
|
||||||
|
|
||||||
def is_numa_available() -> bool:
|
def is_numa_available() -> bool:
|
||||||
try:
|
try:
|
||||||
libnuma = ctypes.CDLL("libnuma.so")
|
libnuma = get_libnuma()
|
||||||
return libnuma.numa_available() >= 0
|
return libnuma.numa_available() >= 0
|
||||||
except Exception:
|
except Exception:
|
||||||
return False
|
return False
|
||||||
|
|||||||
Reference in New Issue
Block a user