示例#1
0
 def start_model_serving_process(self, model_config_path, model_weight_path, pipe_pairs):
     cmd = build_child_cmd(type='model_serving', config=self.config, pipe_pairs=pipe_pairs)
     cmd.extend([
         '--model-config-path', model_config_path,
         '--model-weight-path', model_weight_path,
     ])
     return start_child_proc(cmd=cmd)
示例#2
0
 def start_gtp_server_process(pipe_pairs, config):
     cmd = build_child_cmd(type='gtp_server',
                           config=config,
                           pipe_pairs=pipe_pairs)
     if config.opts.n_minutes:
         cmd.extend(['--n-minutes', f'{config.opts.n_minutes}'])
     return start_child_proc(cmd=cmd, nocuda=True)
示例#3
0
 def start_p1_server(self, gtp_pipe_pair):
     cmd = build_child_cmd(type='gtp_server',
                           config=self.config,
                           pipe_pairs=[gtp_pipe_pair, self.p1_pipe_pair])
     if self.config.opts.n_minutes:
         cmd.extend(['--n-minutes', f'{self.config.opts.n_minutes}'])
     return start_child_proc(cmd=cmd, nocuda=True)
示例#4
0
    def vs(self, player1 : Player, player2 : Player, n_games):

        pipe_pairs = self.pipe_files.make_pipes(1)
        cmd = build_child_cmd(type='versus_n_games', config=self.config, pipe_pairs=reverse_in_out(pipe_pairs))
        cmd.extend([
            '--n-games', f'{n_games}',
            '--n-workers', f'{self.config.opts.n_workers}',
            '--p1-n-sims', f'{player1.n_sims}',
            "--p1-model-config-path", player1.config,
            "--p1-model-weight-path", player1.weight,
            '--p2-n-sims', f'{player2.n_sims}',
            "--p2-model-config-path", player2.config,
            "--p2-model-weight-path", player2.weight,
        ])

        pipe_pairs[0].open_read_nonblock()
        p = start_child_proc(cmd=cmd).wait()

        result = pipe_pairs[0].read_no_empty()
        assert result
        result = result.decode()
        result = result.split(',')
        result = [int(x) for x in result]

        pipe_pairs[0].close_read()
        self.pipe_files.clear_pipes()

        return result
示例#5
0
    def start_1_game_process(self, pps, p1_first):
        cmd = build_child_cmd(type='versus_a_game_kernel', config=self.config, pipe_pairs=pps)
        cmd.extend(['--p1-first', f'{p1_first}'])
        if self.config.opts.save_versus_dir:
            cmd.extend(["--save-versus-dir", self.config.opts.save_versus_dir])
        if self.config.opts.n_minutes:
            cmd.extend(['--n-minutes', f'{self.config.opts.n_minutes}'])

        return start_child_proc(cmd=cmd, nocuda=True)
示例#6
0
    def eval_model(self):

        pipe_pairs = self.pipe_files.make_pipes(1)
        cmd = self.build_versus_n_games_cmd(
            pipe_pairs=reverse_in_out(pipe_pairs))

        pipe_pairs[0].open_read_nonblock()
        start_child_proc(cmd=cmd).wait()

        result = pipe_pairs[0].read_no_empty()
        assert result
        result = result.decode()
        result = result.split(',')
        result = [int(x) for x in result]

        pipe_pairs[0].close_read()
        self.pipe_files.clear_pipes()

        return result
示例#7
0
 def start_http_server_process(self, pipe_pairs, port):
     cmd = build_child_cmd(type='http_server',
                           config=self.config,
                           pipe_pairs=pipe_pairs)
     cmd.extend([
         '--http-port',
         f'{port}',
         '--model-config-path',
         self.config.resource.model_config_path,
         '--model-weight-path',
         self.config.resource.model_weight_path,
     ])
     return start_child_proc(cmd=cmd, nocuda=True)
示例#8
0
    def eval_model_elo(self, to_eval_config_path, to_eval_weight_path):
        rc = self.config.resource

        pipe_pairs = self.pipe_files.make_pipes(1)

        cmd = build_child_cmd(type='elo_p1',
                              config=self.config,
                              pipe_pairs=reverse_in_out(pipe_pairs))
        cmd.extend([
            '--n-games',
            f'{self.config.eval.n_games}',
            '--n-workers',
            f'{self.config.opts.n_workers}',
            "--p1-model-config-path",
            to_eval_config_path,
            "--p1-model-weight-path",
            to_eval_weight_path,
            "--p2-model-config-path",
            rc.model_config_path,
            "--p2-model-weight-path",
            rc.model_weight_path,
            '--p1-elo',
            '0',
            '--p2-elo',
            '0',
        ])
        pipe_pairs[0].open_read_nonblock()
        start_child_proc(cmd=cmd).wait()

        result = pipe_pairs[0].read_no_empty()
        result = result.decode()
        result = result.split(',')
        elo = float(result[0])
        win = int(result[1])
        draw = int(result[2])
        lose = int(result[3])
        self.pipe_files.clear_pipes()

        return elo, win, draw, lose
示例#9
0
    def clear(self):
        if not self.p:
            self.p = start_child_proc(cmd=self.cmd,
                                      nocuda=True,
                                      stdin=PIPE,
                                      stdout=PIPE,
                                      stderr=PIPE,
                                      cwd=self.cwd)
            self.send('nboard 2')
            self.send(f'set depth {self.depth}')

        cmd = 'set game (;' \
              'GM[Othello]' \
              'PC[NBoard]' \
              'DT[2014-02-21 20:52:27 GMT]' \
              'PB[?]' \
              'PW[?]' \
              'RE[?]' \
              'TI[15:00]' \
              'TY[8]' \
              'BO[8 ---------------------------*O------O*--------------------------- *]' \
              ';)'
        self.send(cmd)
示例#10
0
 def start_gtp_server_process(self, pipe_pairs):
     cmd = build_child_cmd(type='gtp_server',
                           config=self.config,
                           pipe_pairs=pipe_pairs)
     return start_child_proc(cmd=cmd, nocuda=True)
示例#11
0
 def start_p2_server(self, gtp_pipe_pair):
     cmd = build_child_cmd(type='gtp_server_ntest',
                           config=self.config,
                           pipe_pairs=[gtp_pipe_pair])
     cmd.extend(['--ntest-depth', f'{self.config.opts.ntest_depth}'])
     return start_child_proc(cmd=cmd, nocuda=True)