File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -529,20 +529,24 @@ def get_numa_aware_cpu_affinity(device_id):
529529 '''
530530 cpu_count = psutil .cpu_count ()
531531
532- # Get the number of bits per ulong
533- c_ulong_bits = ctypes .sizeof (ctypes .c_ulong ) * 8
534-
535- # Determine how large our cpu set array from NVML needs to be
536- cpu_set_size = math .ceil (cpu_count / c_ulong_bits )
537-
538- # If we hit an exception, default to unconstrained CPU affinity
532+ # If this is not a NUMA system, or we hit an exception, default to
533+ # unconstrained CPU affinity
539534 cpu_affinity = list (range (cpu_count ))
540535
536+ if not os .path .isdir ("/sys/devices/system/node/node1" ):
537+ return cpu_affinity
538+
541539 try :
542540 # initialize NVML
543541 import pynvml
544542 pynvml .nvmlInit ()
545543
544+ # Get the number of bits per ulong
545+ c_ulong_bits = ctypes .sizeof (ctypes .c_ulong ) * 8
546+
547+ # Determine how large our cpu set array from NVML needs to be
548+ cpu_set_size = math .ceil (cpu_count / c_ulong_bits )
549+
546550 # Get the optimal CPU affinity for this device according to the NUMA
547551 # topology
548552 handle = pynvml .nvmlDeviceGetHandleByIndex (device_id )
You can’t perform that action at this time.
0 commit comments