-
Notifications
You must be signed in to change notification settings - Fork 0
/
train_slurm.py
45 lines (39 loc) · 2.26 KB
/
train_slurm.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import os
from opts import Options
import time
import shutil
if __name__ == '__main__':
parser = Options()
(configuration, args) = parser.parse_args()
#display = configuration.root + configuration.name + '/display.txt'
configuration.root = configuration.root + configuration.name
configuration.cp_dest = configuration.root + configuration.cp_dest
configuration.im_dest = configuration.root + configuration.im_dest
configuration.tb_dest = configuration.root + configuration.tb_dest
if not os.path.exists(configuration.root):
os.makedirs(configuration.root)
if not os.path.exists(configuration.cp_dest):
os.makedirs(configuration.cp_dest)
if not os.path.exists(configuration.im_dest):
os.makedirs(configuration.im_dest)
if not os.path.exists(configuration.tb_dest):
os.makedirs(configuration.tb_dest)
if os.path.isfile(configuration.root + ('/opts_%s.py' % configuration.name)):
os.remove(configuration.root + ('/opts_%s.py' % configuration.name))
shutil.copy2('opts.py', configuration.root + ('/opts_%s.py' % configuration.name))
if configuration.prenet:
if os.path.isfile(configuration.root + ('/opts2_%s.py' % configuration.name)):
os.remove(configuration.root + ('/opts2_%s.py' % configuration.name))
shutil.copy2('opts2.py', configuration.root + ('/opts2_%s.py' % configuration.name))
if os.path.isfile(configuration.root + ('/train_%s.py' % configuration.name)):
os.remove(configuration.root + ('/train_%s.py' % configuration.name))
shutil.copy2('train.py', configuration.root + ('/train_%s.py' % configuration.name))
train = 'train_%s.py' % configuration.name
if configuration.preprocess_filename != 'None' and os.path.isfile(configuration.preprocess_filename):
print('2D_slices was copied')
shutil.copy2(configuration.preprocess_filename, configuration.cp_dest + '2D_slices.npz')
#if os.path.exists(configuration.root + '/models'):
# shutil.rmtree(configuration.root + '/models')
#shutil.copytree('models', configuration.root + '/models')
# --constraint="12g" -p undergrad --qos=short"pascal
os.system('sbatch -p turing --gres=gpu:%d train_shell.sh %s %s' % (configuration.gpu_devices, configuration.root, train))