def __init__(self, model=None, path=None, reload_every=60 * 60, swap=False, memory=0, delay=0, **kwargs): self.model = RL.Model(model, path, swap=swap, mode=RL.Mode.PLAY, memory=memory, **kwargs) self.reload_every = reload_every self.counter = 0 self.action = 0 self.actions = util.CircularQueue(delay + 1, 0) self.memory = util.CircularQueue(array=((memory + 1) * ssbm.SimpleStateAction)()) self.model.restore()
os.system("sbatch " + slurmfile) #os.system("sbatch -N 1 -c 2 --mem=8000 --time=6-23:00:00 slurm_scripts/" + jobname + ".slurm &") init = False init = True if dry_run: print("NOT starting jobs:") else: print("Starting jobs:") # init model for the first time if init: import RL model = RL.Model(mode=RL.Mode.TRAIN, gpu=False, **job_dicts['train']) model.init() model.save() train_name = "trainer_" + exp_name train_command = "python3 -u train.py" + job_flags['train'] slurm_script(train_name, train_command, gpu=True) #sys.exit() agent_count = 0 agent_command = "python3 -u run.py" + job_flags['agent'] for c1 in characters: for c2 in characters: command = agent_command + " --p1 %s --p2 %s" % (c1, c2)
f.write("#SBATCH --array=1-%d\n" % array) f.write(command) #command = "screen -S %s -dm srun --job-name %s --pty singularity exec -B $OM_USER/phillip -B $HOME/phillip/ -H ../home phillip.img gdb -ex r --args %s" % (name[:10], name, command) os.system("sbatch " + slurmfile) if args.dry_run: print("NOT starting jobs:") else: print("Starting jobs:") # init model for the first time if args.init: import RL model = RL.Model(mode=RL.Mode.TRAIN, **job_dicts['train']) model.init() model.save() import json for k, v in job_dicts.items(): with open(path + k, 'w') as f: json.dump(v, f, indent=2) if run_trainer: train_name = "trainer_" + exp_name train_command = "python3 -u train.py" + job_flags['train'] slurm_script(train_name, train_command, gpu=True,
type=int, default=0, help="how many frames to remember") args = parser.parse_args() if args.name is None: args.name = args.model if args.path is None: args.path = "saves/%s/" % args.name experience_dir = args.path + 'experience/' os.makedirs(experience_dir, exist_ok=True) model = RL.Model(mode=RL.Mode.TRAIN, **args.__dict__) # do this in RL? if args.init: model.init() model.save() else: model.restore() import numpy as np def sweep(data_dir='experience/'): i = 0 start_time = time.time() files = os.listdir(data_dir)
if args.trainer: agent_dump = "172.16.24.%s" % args.trainer run_trainer = False else: trainer_dump = "ib0" run_agents = False if args.dry_run: print("NOT starting jobs:") else: print("Starting jobs:") # init model for the first time if args.init: import RL model = RL.Model(mode=RL.Mode.TRAIN, **params) model.init() model.save() if not os.path.exists("slurm_logs"): os.makedirs("slurm_logs") if not os.path.exists("slurm_scripts"): os.makedirs("slurm_scripts") def launch(name, command, cpus=2, mem=1000, gpu=False, log=True, qos=None, array=None): #command = "LD_PRELOAD=$OM_USER/lib/libtcmalloc.so.4 " + command if args.dry_run: print(command) return