Skip to content
Snippets Groups Projects
Commit 240b113f authored by Franck Dary's avatar Franck Dary
Browse files

Added device argument to launchBatches.py

parent b74a8e24
No related branches found
No related tags found
No related merge requests found
...@@ -7,7 +7,7 @@ import time ...@@ -7,7 +7,7 @@ import time
############################################################################### ###############################################################################
def printUsageAndExit() : def printUsageAndExit() :
print("USAGE : %s (train | eval) (bash | oar | slurm) batchesDescription.py (--time nbHours)"%sys.argv[0], file=sys.stderr) print("USAGE : %s (train | eval) (bash | oar | slurm) (gpu | cpu) batchesDescription.py (--time nbHours)"%sys.argv[0], file=sys.stderr)
exit(1) exit(1)
############################################################################### ###############################################################################
...@@ -18,11 +18,11 @@ def prepareExperiment(lang, template, expName) : ...@@ -18,11 +18,11 @@ def prepareExperiment(lang, template, expName) :
############################################################################### ###############################################################################
############################################################################### ###############################################################################
def launchTrain(mode, expName, arguments, launcher, nbHours, seed) : def launchTrain(device, mode, expName, arguments, launcher, nbHours, seed) :
if launcher == "bash" : if launcher == "bash" :
launchTrainBash(mode, expName, arguments, seed) launchTrainBash(mode, expName, arguments, seed)
elif launcher == "oar" : elif launcher == "oar" :
launchTrainOar(mode, expName, arguments, nbHours, seed) launchTrainOar(device, mode, expName, arguments, nbHours, seed)
elif launcher == "slurm" : elif launcher == "slurm" :
launchTrainSlurm(mode, expName, arguments, nbHours, seed) launchTrainSlurm(mode, expName, arguments, nbHours, seed)
else : else :
...@@ -41,7 +41,7 @@ def nbMaxLongJobs() : ...@@ -41,7 +41,7 @@ def nbMaxLongJobs() :
############################################################################### ###############################################################################
############################################################################### ###############################################################################
def launchTrainOar(mode, expName, arguments, nbHours, seed) : def launchTrainOar(device, mode, expName, arguments, nbHours, seed) :
bestEffort = getOarNbLongJobs() >= nbMaxLongJobs() bestEffort = getOarNbLongJobs() >= nbMaxLongJobs()
command = "oarsub" command = "oarsub"
...@@ -50,8 +50,12 @@ def launchTrainOar(mode, expName, arguments, nbHours, seed) : ...@@ -50,8 +50,12 @@ def launchTrainOar(mode, expName, arguments, nbHours, seed) :
command += " -n train:%s"%expName command += " -n train:%s"%expName
command += " -E %s.stderr"%expName command += " -E %s.stderr"%expName
command += " -O %s.stdout"%expName command += " -O %s.stdout"%expName
if device == "gpu" :
command += " -p \"gpu IS NOT NULL%s\""%getBestHostConstraint() command += " -p \"gpu IS NOT NULL%s\""%getBestHostConstraint()
command += " -l walltime=%d:00:00"%nbHours command += " -l walltime=%d:00:00"%nbHours
else :
command += " -p \"gpu IS NULL\""
command += " -l /core=4,walltime=%d:00:00"%nbHours
command += " \'" + "./train.sh %s bin/%s %s --silent --seed"%(mode,expName,arguments,seed) + "\'" command += " \'" + "./train.sh %s bin/%s %s --silent --seed"%(mode,expName,arguments,seed) + "\'"
subprocess.Popen(command, shell=True).wait() subprocess.Popen(command, shell=True).wait()
...@@ -88,11 +92,11 @@ module load python/3.7.5 ...@@ -88,11 +92,11 @@ module load python/3.7.5
############################################################################### ###############################################################################
############################################################################### ###############################################################################
def launchEval(mode, expName, launcher, nbHours) : def launchEval(device, mode, expName, launcher, nbHours) :
if launcher == "bash" : if launcher == "bash" :
launchEvalBash(mode, expName) launchEvalBash(mode, expName)
elif launcher == "oar" : elif launcher == "oar" :
launchEvalOar(mode, expName, nbHours) launchEvalOar(device, mode, expName, nbHours)
elif launcher == "slurm" : elif launcher == "slurm" :
launchEvalSlurm(mode, expName, nbHours) launchEvalSlurm(mode, expName, nbHours)
else : else :
...@@ -106,7 +110,7 @@ def launchEvalBash(mode, expName) : ...@@ -106,7 +110,7 @@ def launchEvalBash(mode, expName) :
############################################################################### ###############################################################################
############################################################################### ###############################################################################
def launchEvalOar(mode, expName, nbHours) : def launchEvalOar(device, mode, expName, nbHours) :
bestEffort = getOarNbLongJobs() >= nbMaxLongJobs() and nbHours > 10 bestEffort = getOarNbLongJobs() >= nbMaxLongJobs() and nbHours > 10
command = "oarsub" command = "oarsub"
...@@ -115,8 +119,12 @@ def launchEvalOar(mode, expName, nbHours) : ...@@ -115,8 +119,12 @@ def launchEvalOar(mode, expName, nbHours) :
command += " -n eval:%s"%expName command += " -n eval:%s"%expName
command += " -E %s.stderr"%expName command += " -E %s.stderr"%expName
command += " -O %s.stdout"%expName command += " -O %s.stdout"%expName
if device == "gpu" :
command += " -p \"gpu IS NOT NULL%s\""%getBestHostConstraint() command += " -p \"gpu IS NOT NULL%s\""%getBestHostConstraint()
command += " -l walltime=%d:00:00"%nbHours command += " -l walltime=%d:00:00"%nbHours
else :
command += " -p \"gpu IS NULL\""
command += " -l /core=4,walltime=%d:00:00"%nbHours
command += " \"" + "./evaluate.sh %s bin/%s --silent"%(mode,expName) + "\"" command += " \"" + "./evaluate.sh %s bin/%s --silent"%(mode,expName) + "\""
subprocess.Popen(command, shell=True).wait() subprocess.Popen(command, shell=True).wait()
...@@ -233,23 +241,24 @@ def getBestHostConstraint() : ...@@ -233,23 +241,24 @@ def getBestHostConstraint() :
############################################################################### ###############################################################################
if __name__ == "__main__" : if __name__ == "__main__" :
if len(sys.argv) < 4 : if len(sys.argv) < 5 :
printUsageAndExit() printUsageAndExit()
mode = sys.argv[1] mode = sys.argv[1]
launcher = sys.argv[2] launcher = sys.argv[2]
batchesDescription = sys.argv[3] device = sys.argv[3]
batchesDescription = sys.argv[4]
nbHours = 92 nbHours = 92
if len(sys.argv) > 4 : if len(sys.argv) > 5 :
if sys.argv[4] == "--time" : if sys.argv[5] == "--time" :
if 5 not in range(4,len(sys.argv)) : if 6 not in range(5,len(sys.argv)) :
printUsageAndExit() printUsageAndExit()
nbHours = int(sys.argv[5]) nbHours = int(sys.argv[6])
else : else :
printUsageAndExit() printUsageAndExit()
if mode not in ["train","eval"] or launcher not in ["bash","oar","slurm"] : if mode not in ["train","eval"] or launcher not in ["bash","oar","slurm"] or device not in ["cpu","gpu"] :
printUsageAndExit() printUsageAndExit()
desc = __import__(os.path.splitext(batchesDescription)[0]) desc = __import__(os.path.splitext(batchesDescription)[0])
...@@ -261,9 +270,9 @@ if __name__ == "__main__" : ...@@ -261,9 +270,9 @@ if __name__ == "__main__" :
xp['expName'] = xp['expName'].split('.')[0]+"."+lang+"."+str(i) xp['expName'] = xp['expName'].split('.')[0]+"."+lang+"."+str(i)
if mode == "train" : if mode == "train" :
prepareExperiment(xp['lang'],xp['template'],xp['expName']) prepareExperiment(xp['lang'],xp['template'],xp['expName'])
launchTrain(xp['mode'],xp['expName'],xp['arguments'],launcher,nbHours,seed=100+i) launchTrain(device,xp['mode'],xp['expName'],xp['arguments'],launcher,nbHours,seed=100+i)
else : else :
launchEval(xp['mode'],xp['expName'],launcher,nbHours) launchEval(device,xp['mode'],xp['expName'],launcher,nbHours)
############################################################################### ###############################################################################
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment