@@ -459,16 +459,17 @@ def runSelected(opt):
459459 opt = parser .parse_args ()
460460 opt .selected_gpus = None
461461
462- if opt .gpu != 'forbidden' :
462+ if not opt . wmcontrol and opt .gpu != 'forbidden' :
463463
464464 print (">> Running with --gpu option. Checking the available and supported GPUs." )
465465 gpus = cleanComputeCapabilities ("cuda" )
466466 gpus = gpus + cleanComputeCapabilities ("rocm" , len (gpus ))
467467 available_gpus = gpus
468468
469469 if len (available_gpus ) == 0 :
470+ if opt .gpu == 'required' :
471+ raise Exception ('Launched with --gpu required and no GPU available!' )
470472 print (">> No GPU available!" )
471- opt .gpu = 'forbidden'
472473 else :
473474 print (">> GPUs available:" )
474475 [print (f ) for f in available_gpus ]
@@ -485,14 +486,18 @@ def runSelected(opt):
485486 print (">> GPUs selected:" )
486487 [print (f ) for f in gpus ]
487488 else :
489+ if opt .gpu == 'required' :
490+ raise Exception ('Launched with --gpu required and no GPU selected (among those available)!' )
488491 print (">> No GPU selected!" )
489492 else :
490493 print (">> All selected!" )
491494
492495 if len (gpus ) > 0 :
493496 opt .selected_gpus = cycle (gpus )
494497 else :
495- opt .gpu = 'forbidden'
498+ error_str = 'No GPU selected'
499+ if opt .gpu == 'required' :
500+ raise Exception ('Launched with --gpu required and no GPU available (among those available)!' )
496501
497502 if opt .command : opt .command = ' ' .join (opt .command )
498503 os .environ ["CMSSW_DAS_QUERY_SITES" ]= opt .dasSites
0 commit comments