diff --git a/UD_any/launchForCluster.py b/UD_any/launchForCluster.py index a2ec37a96848a62bb0255d27300851e1f48fe246..28c1237a89eb616ae4652024fb861f695625da5a 100755 --- a/UD_any/launchForCluster.py +++ b/UD_any/launchForCluster.py @@ -4,6 +4,9 @@ import sys import os import time +cluster = "LIS" +#cluster = "MESOCENTRE" + prefix = "#SBATCH " account = "-A b177" shell = "#! /bin/bash" @@ -16,7 +19,7 @@ stdoutStr = "-o %x.stdout" stderrStr = "-e %x.stderr" modules = ["userspace/all", "boost/gcc72/1.65.1"] configPrefix = "UD_ROOT=~/ud/ud-treebanks-all/" -commandStr = "./train.sh . %s %s --interactive 0 --printTime %s" +commandStr = "time ./train.sh . %s %s --interactive 0 --printTime %s --dictCapacity 100000" def waitUntilDirExists(dirPath) : time.sleep(2.0) @@ -28,39 +31,54 @@ def waitUntilFileExists(filePath) : while not os.path.isfile(filePath) : time.sleep(2.0) -def launchExperiment(jobName,lang,template,nbCpus=1,partition='skylake',time='2-00',moreArgs='') : - - print(configPrefix+lang+'/', file=open('config', 'w')) +def launchExperiment(langChanged, jobName,lang,template,nbCpus=1,partition='skylake',time='2-00',moreArgs='') : - os.system("cd data && make clean && make && cd ..") + if langChanged : + print(configPrefix+lang+'/', file=open('config', 'w')) - waitUntilFileExists('data/tagger.as') + os.system("cd data && make clean && make && cd ..") - slurmFile = open('script.slurm', 'w') + waitUntilFileExists('data/tagger.as') jobName += '_' + lang - print(shell, file=slurmFile) - print(prefix+account, file=slurmFile) - print(prefix+jobNameStr%jobName, file=slurmFile) - print(prefix+partitionStr%partition, file=slurmFile) - print(prefix+memPerCPU, file=slurmFile) - print(prefix+nbCpusStr%nbCpus, file=slurmFile) - print(prefix+timeStr%time, file=slurmFile) - print(prefix+stdoutStr, file=slurmFile) - print(prefix+stderrStr, file=slurmFile) - print("", file=slurmFile) - print("module purge", file=slurmFile) - for module in modules : - print("module load %s"%module, file=slurmFile) - - print("", file=slurmFile) - - print(commandStr%(template,jobName,moreArgs), file=slurmFile) - - slurmFile.close() - - os.system("sbatch script.slurm") + if cluster == "MESOCENTRE" : + slurmFile = open('script.slurm', 'w') + + print(shell, file=slurmFile) + print(prefix+account, file=slurmFile) + print(prefix+jobNameStr%jobName, file=slurmFile) + print(prefix+partitionStr%partition, file=slurmFile) + print(prefix+memPerCPU, file=slurmFile) + print(prefix+nbCpusStr%nbCpus, file=slurmFile) + print(prefix+timeStr%time, file=slurmFile) + print(prefix+stdoutStr, file=slurmFile) + print(prefix+stderrStr, file=slurmFile) + print("", file=slurmFile) + print("module purge", file=slurmFile) + for module in modules : + print("module load %s"%module, file=slurmFile) + + print("", file=slurmFile) + + print(commandStr%(template,jobName,moreArgs), file=slurmFile) + + slurmFile.close() + + os.system("sbatch script.slurm") + elif cluster == "LIS" : + command = "oarsub" + command += " -t besteffort" + command += " -n %s"%jobName + command += " -E %s.stderr"%jobName + command += " -O %s.stdout"%jobName + command += " -p \"gpu IS NULL\"" + command += " -l walltime=96:00:00" + command += " \"" + commandStr%(template,jobName,moreArgs) + "\"" + os.system(command) + else : + print("ERROR : not a valid cluster \'%s\'"%cluster) + exit(1) waitUntilDirExists('bin/'+jobName+'/data/') @@ -77,8 +95,11 @@ if __name__ == "__main__" : langs = ["UD_French-GSD", "UD_Hebrew-HTB", "UD_Chinese-GSD", "UD_English-EWT"] - for experience in templatesExperiments : - for lang in langs : + for lang in langs : + langChanged = True + for experience in templatesExperiments : experience['lang'] = lang + experience['langChanged'] = langChanged launchExperiment(**experience) + langChanged = False