Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
macaon_data
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Franck Dary
macaon_data
Commits
10f112e5
Commit
10f112e5
authored
4 years ago
by
Franck Dary
Browse files
Options
Downloads
Patches
Plain Diff
Added slurm support to launchBatches
parent
e73391bf
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitignore
+1
-0
1 addition, 0 deletions
.gitignore
UD_any/launchBatches.py
+63
-4
63 additions, 4 deletions
UD_any/launchBatches.py
with
64 additions
and
4 deletions
.gitignore
+
1
−
0
View file @
10f112e5
bin/
*\.stderr
*\.stdout
*\.slurm
__pycache__
config
This diff is collapsed.
Click to expand it.
UD_any/launchBatches.py
+
63
−
4
View file @
10f112e5
...
...
@@ -3,11 +3,11 @@
import
sys
import
os
import
subprocess
import
time
###############################################################################
def
printUsageAndExit
()
:
print
(
"
USAGE : %s (train | eval) (bash | oar) batchesDescription.py (--time nbHours)
"
%
sys
.
argv
[
0
],
file
=
sys
.
stderr
)
print
(
"
USAGE : %s (train | eval) (bash | oar | slurm) batchesDescription.py (--time nbHours)
"
%
sys
.
argv
[
0
],
file
=
sys
.
stderr
)
exit
(
1
)
###############################################################################
...
...
@@ -23,6 +23,8 @@ def launchTrain(mode, expName, arguments, launcher, nbHours) :
launchTrainBash
(
mode
,
expName
,
arguments
)
elif
launcher
==
"
oar
"
:
launchTrainOar
(
mode
,
expName
,
arguments
,
nbHours
)
elif
launcher
==
"
slurm
"
:
launchTrainSlurm
(
mode
,
expName
,
arguments
,
nbHours
)
else
:
printUsageAndExit
()
###############################################################################
...
...
@@ -55,12 +57,42 @@ def launchTrainOar(mode, expName, arguments, nbHours) :
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
)
:
if
launcher
==
"
bash
"
:
launchEvalBash
(
mode
,
expName
)
elif
launcher
==
"
oar
"
:
launchEvalOar
(
mode
,
expName
,
nbHours
)
elif
launcher
==
"
slurm
"
:
launchEvalSlurm
(
mode
,
expName
,
nbHours
)
else
:
printUsageAndExit
()
###############################################################################
...
...
@@ -88,11 +120,38 @@ def launchEvalOar(mode, expName, nbHours) :
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
()
:
return
int
(
subprocess
.
Popen
(
'
oarstat -u | grep
"
Q=long
"
| wc -l
'
,
shell
=
True
,
stdout
=
subprocess
.
PIPE
).
stdout
.
read
())
###############################################################################
###############################################################################
...
...
@@ -181,7 +240,7 @@ if __name__ == "__main__" :
else
:
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
()
desc
=
__import__
(
os
.
path
.
splitext
(
batchesDescription
)[
0
])
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment