@@ -450,32 +450,42 @@ def runSelected(opt):
450450 default = '' )
451451
452452 opt = parser .parse_args ()
453-
454453 opt .selected_gpus = None
455- if opt .gpu :
454+
455+ if opt .gpu != 'forbidden' :
456456
457457 print (">> Running with --gpu option. Checking the available and supported GPUs." )
458458 gpus = cleanComputeCapabilities ("cuda" )
459459 gpus = gpus + cleanComputeCapabilities ("rocm" , len (gpus ))
460460 available_gpus = gpus
461461
462- print ("> GPUs Available:" )
463- [print (f ) for f in available_gpus ]
462+ if len (available_gpus ) == 0 :
463+ print (">> No GPU available!" )
464+ opt .gpu = 'forbidden'
465+ else :
466+ print (">> GPUs available:" )
467+ [print (f ) for f in available_gpus ]
464468
465- # Filtering ONLY CUDA GPUs on capability
466- gpus = [g for g in gpus if not g .isCUDA () or (g .isCUDA () and g .capability in opt .CUDACapabilities )]
469+ # Filtering ONLY CUDA GPUs on capability
470+ gpus = [g for g in gpus if not g .isCUDA () or (g .isCUDA () and g .capability in opt .CUDACapabilities )]
467471
468- # Filtering by name (if parsed)
469- if len (opt .GPUName ) > 0 :
470- gpus = [g for g in gpus if g .name == opt .GPUName ]
472+ # Filtering by name (if parsed)
473+ if len (opt .GPUName ) > 0 :
474+ gpus = [g for g in gpus if g .name == opt .GPUName ]
471475
472- if available_gpus != gpus :
473- print (">> Selected:" )
474- [print (f ) for f in gpus ]
475- else :
476- print (">> All selected!" )
477-
478- opt .selected_gpus = cycle (gpus )
476+ if available_gpus != gpus :
477+ if len (gpus ) > 0 :
478+ print (">> GPUs selected:" )
479+ [print (f ) for f in gpus ]
480+ else :
481+ print (">> No GPU selected!" )
482+ else :
483+ print (">> All selected!" )
484+
485+ if len (gpus ) > 0 :
486+ opt .selected_gpus = cycle (gpus )
487+ else :
488+ opt .gpu = 'forbidden'
479489
480490 if opt .command : opt .command = ' ' .join (opt .command )
481491 os .environ ["CMSSW_DAS_QUERY_SITES" ]= opt .dasSites
0 commit comments