Skip to content

Commit c1c8c36

Browse files
committed
slurm2sql: Add GPUType as a field
1 parent 6d91f07 commit c1c8c36

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

slurm2sql.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ def calc(row):
373373

374374

375375
gpu_re2 = re.compile(r'gpu=(\d+)')
376+
gpu_re2_type = re.compile(rf'\bgres/gpu:([^=]+)=\b')
376377
class slurmGPUCount(linefunc):
377378
type = 'int'
378379
@staticmethod
@@ -382,6 +383,14 @@ def calc(row):
382383
m = gpu_re2.search(tres)
383384
if m:
384385
return int(m.group(1))
386+
class slurmGPUType(linefunc):
387+
type = 'text'
388+
@staticmethod
389+
def calc(row):
390+
if not row['AllocTRES']: return None
391+
m = gpu_re2_type.search(row['AllocTRES'])
392+
if m:
393+
return m.group(1)
385394

386395
RE_TRES_GPU = re.compile(rf'\bgres/gpu=([^,]*)\b')
387396
RE_TRES_GPU_UTIL = re.compile(rf'\bgres/gpuutil=([^,]*)\b')
@@ -649,6 +658,7 @@ def calc(row):
649658
'_GpuEff': slurmGPUEff2, # GPU utilization (0.0 to 1.0) from AllocTRES()
650659
#'_NGPU': slurmGPUCount, # Number of GPUs, extracted from comment field
651660
'_NGpus': ExtractField('NGpus', 'AllocTRES', 'gres/gpu', float_metric),
661+
'_GpuType': slurmGPUType, # gres/gpu:TYPE= from AllocTres
652662
'_GpuUtil': ExtractField('GpuUtil', 'TRESUsageInAve', 'gres/gpuutil', float_metric, wrap=lambda x: x/100.), # can be >100 for multi-GPU.
653663
'_GpuMem': ExtractField('GpuMem2', 'TRESUsageInAve', 'gres/gpumem', float_metric),
654664
'_GpuUtilTot': ExtractField('GpuUtilTot', 'TRESUsageInTot', 'gres/gpuutil', float_metric),
@@ -921,6 +931,7 @@ def infer_type(cd):
921931
'max(MemEff) AS MemEff, '
922932
'max(AllocMem*Elapsed) AS mem_s_reserved, ' # highest of any job
923933
'max(NGpus) AS NGpus, '
934+
'max(GPUType) AS GPUType, '
924935
'max(NGpus)*max(Elapsed) AS gpu_s_reserved, '
925936
'max(NGpus)*max(Elapsed)*max(GPUutil) AS gpu_s_used, '
926937
#'max(GPUutil)/max(NGpus) AS GPUeff, ' # Individual job with highest use (check this)

0 commit comments

Comments
 (0)