diff --git a/UD_any/launchBatches.py b/UD_any/launchBatches.py index 2e0b3df8e19f2c44c5a5c1925efc4182c0fbe357..d29fdb1876fbb8bf135fa1f1725ce4655d453ffa 100755 --- a/UD_any/launchBatches.py +++ b/UD_any/launchBatches.py @@ -111,21 +111,31 @@ def getOarNbGpuPerNode() : ############################################################################### def getOarNbUsedGpuPerNode() : - l = subprocess.Popen("oarstat -f | grep 'assigned_hostnames =\|propert' | grep -i 'gpu is not null' -C 1 | sed '0~2d' | sort | uniq -c | awk '{print $4,$1}'", shell=True, stdout=subprocess.PIPE).stdout.read().decode("utf8").split('\n') + l = subprocess.Popen("oarstat -f | grep 'assigned_hostnames =\|propert\|wanted_resources' | grep -i 'gpu is not null' -B 2 | grep [^-]", shell=True, stdout=subprocess.PIPE).stdout.read().decode("utf8").split('\n') res = {} - for line in l : - splited = line.split() - if len(splited) != 2 : - continue - res[splited[0]] = int(splited[1]) + + for i in range(len(l)//3) : + ressources = l[3*i] + hostname = l[3*i+1].split()[-1] + cores = 1 + gpunum = 1 + if "core=" in ressources : + cores = int(ressources.split("core=")[-1].split('/')[0]) + if "gpunum=" in ressources : + gpunum = int(ressources.split("gpunum=")[-1].split(',')[0]) + + if hostname not in res : + res[hostname] = 0 + res[hostname] += cores * gpunum return res ############################################################################### ############################################################################### def getOarNotAliveNodes() : - return subprocess.Popen("oarnodes | grep -B 2 'state : [^A]' | grep 'network_address' | sort --unique | awk '{print $3}'", shell=True, stdout=subprocess.PIPE).stdout.read().decode("utf8").split('\n') + res = subprocess.Popen("oarnodes | grep -B 2 'state : [^A]' | grep 'network_address' | sort --unique | awk '{print $3}'", shell=True, stdout=subprocess.PIPE).stdout.read().decode("utf8").split('\n') + return [node for node in res if len(node) > 0] ############################################################################### ###############################################################################