@@ -732,17 +732,18 @@ def worker(
732732 os .sched_setaffinity (0 , my_cores ) # type: ignore[attr-defined, unused-ignore]
733733 logger .info ("Set worker CPU affinity to {}" .format (my_cores ))
734734
735- # If CUDA devices, find total number of devices to allow for MPS
736- # See: https://developer.nvidia.com/system-management-interface
737- nvidia_smi_cmd = "nvidia-smi -L > /dev/null && nvidia-smi -L | wc -l"
738- nvidia_smi_ret = subprocess .run (nvidia_smi_cmd , shell = True , stdout = subprocess .PIPE , stderr = subprocess .PIPE )
739- if nvidia_smi_ret .returncode == 0 :
740- num_cuda_devices = int (nvidia_smi_ret .stdout .split ()[0 ])
741- else :
742- num_cuda_devices = None
743-
744735 # If desired, pin to accelerator
745736 if accelerator is not None :
737+
738+ # If CUDA devices, find total number of devices to allow for MPS
739+ # See: https://developer.nvidia.com/system-management-interface
740+ nvidia_smi_cmd = "nvidia-smi -L > /dev/null && nvidia-smi -L | wc -l"
741+ nvidia_smi_ret = subprocess .run (nvidia_smi_cmd , shell = True , stdout = subprocess .PIPE , stderr = subprocess .PIPE )
742+ if nvidia_smi_ret .returncode == 0 :
743+ num_cuda_devices = int (nvidia_smi_ret .stdout .split ()[0 ])
744+ else :
745+ num_cuda_devices = None
746+
746747 try :
747748 if num_cuda_devices is not None :
748749 procs_per_cuda_device = pool_size // num_cuda_devices
0 commit comments