File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -165,10 +165,14 @@ def get_nvidia_devices(self, use_docker=True):
165165 remove = True ,
166166 )
167167 gpu_info = output .decode ()
168- if gpu_info .find ("==========" ) != - 1 : # need to remove header
169- gpus = gpu_info .split ("\n " )[15 :- 1 ]
170- else :
171- gpus = gpu_info .split ("\n " )[:- 1 ]
168+ GPU_REGEX = r"(\d+), (?:GPU-)?([a-fA-F0-9-]+)"
169+ gpus = {}
170+ for line in gpu_info .splitlines ():
171+ match = re .match (GPU_REGEX , line )
172+ if match :
173+ idx = match .group (1 )
174+ uuid = match .group (2 )
175+ gpus [idx ] = uuid
172176
173177 else :
174178 # use the singularity runtime to run nvidia-smi
@@ -177,10 +181,10 @@ def get_nvidia_devices(self, use_docker=True):
177181 # if output['return_code'] != 0:
178182 # raise SingularityError
179183 # gpus = output['message']
180- gpus = []
184+ gpus = {}
181185 # Get newline delimited gpu-index, gpu-uuid list
182186 logger .info ("GPUs: " + str (gpus ))
183- return { gpu . split ( ',' )[ 0 ]. strip (): gpu . split ( ',' )[ 1 ]. strip () for gpu in gpus }
187+ return gpus
184188
185189 @wrap_exception ('Unable to fetch Docker container ip' )
186190 def get_container_ip (self , network_name : str , container_id : str ):
You can’t perform that action at this time.
0 commit comments