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
###############################################################################
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)
###############################################################################
......@@ -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" :
launchTrainBash(mode, expName, arguments, seed)
elif launcher == "oar" :
launchTrainOar(mode, expName, arguments, nbHours, seed)
launchTrainOar(device, mode, expName, arguments, nbHours, seed)
elif launcher == "slurm" :
launchTrainSlurm(mode, expName, arguments, nbHours, seed)
else :
......@@ -41,7 +41,7 @@ def nbMaxLongJobs() :
###############################################################################
###############################################################################
def launchTrainOar(mode, expName, arguments, nbHours, seed) :
def launchTrainOar(device, mode, expName, arguments, nbHours, seed) :
bestEffort = getOarNbLongJobs() >= nbMaxLongJobs()
command = "oarsub"
......@@ -50,8 +50,12 @@ def launchTrainOar(mode, expName, arguments, nbHours, seed) :
command += " -n train:%s"%expName
command += " -E %s.stderr"%expName
command += " -O %s.stdout"%expName
command += " -p \"gpu IS NOT NULL%s\""%getBestHostConstraint()
command += " -l walltime=%d:00:00"%nbHours
if device == "gpu" :
command += " -p \"gpu IS NOT NULL%s\""%getBestHostConstraint()
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) + "\'"
subprocess.Popen(command, shell=True).wait()
......@@ -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" :
launchEvalBash(mode, expName)
elif launcher == "oar" :
launchEvalOar(mode, expName, nbHours)
launchEvalOar(device, mode, expName, nbHours)
elif launcher == "slurm" :
launchEvalSlurm(mode, expName, nbHours)
else :
......@@ -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
command = "oarsub"
......@@ -115,8 +119,12 @@ def launchEvalOar(mode, expName, nbHours) :
command += " -n eval:%s"%expName
command += " -E %s.stderr"%expName
command += " -O %s.stdout"%expName
command += " -p \"gpu IS NOT NULL%s\""%getBestHostConstraint()
command += " -l walltime=%d:00:00"%nbHours
if device == "gpu" :
command += " -p \"gpu IS NOT NULL%s\""%getBestHostConstraint()
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) + "\""
subprocess.Popen(command, shell=True).wait()
......@@ -233,23 +241,24 @@ def getBestHostConstraint() :
###############################################################################
if __name__ == "__main__" :
if len(sys.argv) < 4 :
if len(sys.argv) < 5 :
printUsageAndExit()
mode = sys.argv[1]
launcher = sys.argv[2]
batchesDescription = sys.argv[3]
device = sys.argv[3]
batchesDescription = sys.argv[4]
nbHours = 92
if len(sys.argv) > 4 :
if sys.argv[4] == "--time" :
if 5 not in range(4,len(sys.argv)) :
if len(sys.argv) > 5 :
if sys.argv[5] == "--time" :
if 6 not in range(5,len(sys.argv)) :
printUsageAndExit()
nbHours = int(sys.argv[5])
nbHours = int(sys.argv[6])
else :
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()
desc = __import__(os.path.splitext(batchesDescription)[0])
......@@ -261,9 +270,9 @@ if __name__ == "__main__" :
xp['expName'] = xp['expName'].split('.')[0]+"."+lang+"."+str(i)
if mode == "train" :
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 :
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.
Finish editing this message first!
Please register or to comment