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

Added slurm support to launchBatches

parent e73391bf
No related branches found
No related tags found
No related merge requests found
bin/ bin/
*\.stderr *\.stderr
*\.stdout *\.stdout
*\.slurm
__pycache__ __pycache__
config config
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
import sys import sys
import os import os
import subprocess import subprocess
import time
############################################################################### ###############################################################################
def printUsageAndExit() : def printUsageAndExit() :
print("USAGE : %s (train | eval) (bash | oar) batchesDescription.py (--time nbHours)"%sys.argv[0], print("USAGE : %s (train | eval) (bash | oar | slurm) batchesDescription.py (--time nbHours)"%sys.argv[0], file=sys.stderr)
file=sys.stderr)
exit(1) exit(1)
############################################################################### ###############################################################################
...@@ -23,6 +23,8 @@ def launchTrain(mode, expName, arguments, launcher, nbHours) : ...@@ -23,6 +23,8 @@ def launchTrain(mode, expName, arguments, launcher, nbHours) :
launchTrainBash(mode, expName, arguments) launchTrainBash(mode, expName, arguments)
elif launcher == "oar" : elif launcher == "oar" :
launchTrainOar(mode, expName, arguments, nbHours) launchTrainOar(mode, expName, arguments, nbHours)
elif launcher == "slurm" :
launchTrainSlurm(mode, expName, arguments, nbHours)
else : else :
printUsageAndExit() printUsageAndExit()
############################################################################### ###############################################################################
...@@ -55,12 +57,42 @@ def launchTrainOar(mode, expName, arguments, nbHours) : ...@@ -55,12 +57,42 @@ def launchTrainOar(mode, expName, arguments, nbHours) :
subprocess.Popen(command, shell=True).wait() subprocess.Popen(command, shell=True).wait()
############################################################################### ###############################################################################
###############################################################################
def launchTrainSlurm(mode, expName, arguments, nbHours) :
filename = "train.{}.slurm".format(expName)
sFile = open(filename, "w")
print("""#! /usr/bin/env bash
#SBATCH --job-name=train:{}
#SBATCH --output={}.stdout
#SBATCH --error={}.stderr
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=10
#SBATCH --gres=gpu:1
#SBATCH --hint=nomultithread
#SBATCH --partition=gpu_p1
#SBATCH --time={}:00:00
module purge
module load gcc/9.1.0
module load python/3.7.5
./train.sh {} bin/{} {} --silent
""".format(expName, expName, expName, nbHours, mode, expName, arguments), file=sFile)
sFile.close()
subprocess.Popen("sbatch {}".format(filename), shell=True).wait()
###############################################################################
############################################################################### ###############################################################################
def launchEval(mode, expName, launcher, nbHours) : def launchEval(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(mode, expName, nbHours)
elif launcher == "slurm" :
launchEvalSlurm(mode, expName, nbHours)
else : else :
printUsageAndExit() printUsageAndExit()
############################################################################### ###############################################################################
...@@ -88,11 +120,38 @@ def launchEvalOar(mode, expName, nbHours) : ...@@ -88,11 +120,38 @@ def launchEvalOar(mode, expName, nbHours) :
subprocess.Popen(command, shell=True).wait() subprocess.Popen(command, shell=True).wait()
############################################################################### ###############################################################################
###############################################################################
def launchEvalSlurm(mode, expName, nbHours) :
filename = "eval.{}.slurm".format(expName)
sFile = open(filename, "w")
print("""#! /usr/bin/env bash
#SBATCH --job-name=eval:{}
#SBATCH --output={}.stdout
#SBATCH --error={}.stderr
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=10
#SBATCH --gres=gpu:1
#SBATCH --hint=nomultithread
#SBATCH --partition=gpu_p1
#SBATCH --time={}:00:00
module purge
module load gcc/9.1.0
module load python/3.7.5
./evaluate.sh {} bin/{} --silent
""".format(expName, expName, expName, nbHours, mode, expName), file=sFile)
sFile.close()
subprocess.Popen("sbatch {}".format(filename), shell=True).wait()
###############################################################################
############################################################################### ###############################################################################
def getOarNbLongJobs() : def getOarNbLongJobs() :
return int(subprocess.Popen('oarstat -u | grep "Q=long" | wc -l', return int(subprocess.Popen('oarstat -u | grep "Q=long" | wc -l',
shell=True, stdout=subprocess.PIPE).stdout.read()) shell=True, stdout=subprocess.PIPE).stdout.read())
############################################################################### ###############################################################################
############################################################################### ###############################################################################
...@@ -181,7 +240,7 @@ if __name__ == "__main__" : ...@@ -181,7 +240,7 @@ if __name__ == "__main__" :
else : else :
printUsageAndExit() printUsageAndExit()
if mode not in ["train","eval"] or launcher not in ["bash","oar"] : if mode not in ["train","eval"] or launcher not in ["bash","oar","slurm"] :
printUsageAndExit() printUsageAndExit()
desc = __import__(os.path.splitext(batchesDescription)[0]) desc = __import__(os.path.splitext(batchesDescription)[0])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment