Commit 9a784a4c by ZhangLingbo

update for alphazero-general/pk, using zmq, tested ok!

parent 2b12bc82
No preview for this file type
...@@ -13,7 +13,8 @@ def main(): ...@@ -13,7 +13,8 @@ def main():
assert(mlu_id < 4 and mlu_id >= 0) assert(mlu_id < 4 and mlu_id >= 0)
context = zmq.Context() context = zmq.Context()
socket = context.socket(zmq.REQ) socket = context.socket(zmq.REQ)
socket.connect('tcp://10.34.134.204:1238') # socket.connect('tcp://10.34.134.204:1238')
socket.connect('tcp://10.37.199.62:1238')
socket.send('') socket.send('')
while True: while True:
task = socket.recv().split('-') task = socket.recv().split('-')
......
...@@ -178,6 +178,8 @@ def play(total_game): ...@@ -178,6 +178,8 @@ def play(total_game):
if m == '': if m == '':
continue continue
black, white, bwin = m.split('-') black, white, bwin = m.split('-')
if bwin == "nan":
continue
elo.playgame(black, white, float(bwin)) elo.playgame(black, white, float(bwin))
complete_game += 1 complete_game += 1
sys.stdout.write('{}/{} games completed, taking {:.1f}s\r'.format(complete_game, total_game, time.time() - tstart)) sys.stdout.write('{}/{} games completed, taking {:.1f}s\r'.format(complete_game, total_game, time.time() - tstart))
......
...@@ -4,38 +4,23 @@ import time ...@@ -4,38 +4,23 @@ import time
import os import os
import commands as cmd import commands as cmd
pj_dir = "/share/2_sxk_mlu_alphago_" def get_cmd(num_games, mlu, model1, model2):
data_dir = "/share/data_sxk"
model_dir = "/share/elo-rating/models/"
def get_cmd(num_games, mlu, model1, model2, rollout, c_puct, rollouts0 = '-1', rollouts1 = '-1'):
cmd_str = "" cmd_str = ""
cmd_str += "%s " % (os.path.join(pj_dir, "build", "pk")) cmd_str += "/share/alphazero-general/build/pk "
cmd_str += "--eval_game_num %d " %(num_games) cmd_str += "--eval_game_num %d " %(num_games)
cmd_str += "--mlu_list_0 %d "%(mlu) cmd_str += "--device_id %d "%(mlu)
cmd_str += "--mlu_list_1 %d "%(mlu) cmd_str += "--device_num 1 "
cmd_str += "--config_path_0 %s "%(os.path.join('/share/elo-rating', "etc", "9_pk_offline_1.4.0.conf")) cmd_str += "--config_path_p1_mcts /share/alphazero-general/go9/etc/pk_p1_mcts.conf "
cmd_str += "--config_path_1 %s "%(os.path.join('/share/elo-rating', "etc", "9_pk_offline_1.4.0.conf")) cmd_str += "--config_path_p1_eval /share/alphazero-general/go9/etc/pk_p1_eval.conf "
cmd_str += "--config_path_p2_mcts /share/alphazero-general/go9/etc/pk_p2_mcts.conf "
cmd_str += "--config_path_p2_eval /share/alphazero-general/go9/etc/pk_p2_eval.conf "
cmd_str += "--model_path_0 %s "%(model1) cmd_str += "--model_path_0 %s "%(model1)
cmd_str += "--model_path_1 %s "%(model2) cmd_str += "--model_path_1 %s "%(model2)
cmd_str += "--rollout_0 %d "%(rollout)
cmd_str += "--rollout_1 %d "%(rollout)
cmd_str += "--rollouts_0 %s "%(rollouts0)
cmd_str += "--rollouts_1 %s "%(rollouts1)
cmd_str += "--c_puct_0 %f "%(c_puct)
cmd_str += "--c_puct_1 %f "%(c_puct)
# TODO: check this
# cmd_str += "--result_path %s "%("-1") # cmd_str += "--result_path %s "%("-1")
return cmd_str return cmd_str
def pk(model1, model2, num_games = 1, mlu_id = 0, rollouts1='-1', rollouts2 = '-1'): def pk(model1, model2, num_games = 1, mlu_id = 0, rollouts1='-1', rollouts2 = '-1'):
rollout = 200 cmd_str = get_cmd(num_games, mlu_id, model1, model2)
if rollouts1 != '-1':
assert(rollouts2 != '-1')
rollout = -1
c_puct = 1.5
model1 = model_dir + model1
model2 = model_dir + model2
cmd_str = get_cmd(num_games, mlu_id, model1, model2, rollout, c_puct, rollouts1, rollouts2)
s, o = cmd.getstatusoutput(cmd_str) s, o = cmd.getstatusoutput(cmd_str)
# os.system(cmd_str) # os.system(cmd_str)
if (s != 0): if (s != 0):
......
No preview for this file type
This source diff could not be displayed because it is too large. You can view the blob instead.
config_0: /share/elo-rating/etc/9_pk_offline_1.4.0.conf config_p1_eval: /share/alphazero-general/go9/etc/pk_p1_eval.conf
config_1: /share/elo-rating/etc/9_pk_offline_1.4.0.conf config_p1_mcts: /share/alphazero-general/go9/etc/pk_p1_mcts.conf
model_0: /share/elo-rating/models/test79_2000 config_p2_eval: /share/alphazero-general/go9/etc/pk_p2_eval.conf
model_1: /share/elo-rating/models/test79_0 config_p2_mcts: /share/alphazero-general/go9/etc/pk_p2_mcts.conf
cpuct_0: 1.5 model_p1: /share/backup_data/go9/test_1/off_models/go9_iter_160000.cambricon
cpuct_1: 1.5 model_p2: /share/backup_data/go9/test_0/off_models/go9_iter_260000.cambricon
eval_num_0: 15526 P2 win rat
eval_num_1: 15337 \ No newline at end of file
0
ulimit -c 0 ulimit -c 0
pip install zmq # pip install zmq
apt-get update
apt-get install -y python-zmq
cd /share/elo-rating cd /share/elo-rating
./ELO_client_test.py 0 & ./ELO_client_test.py 1 & ./ELO_client_test.py 2 & ./ELO_client_test.py 3 ./ELO_client_test.py 0 & ./ELO_client_test.py 1 & ./ELO_client_test.py 2 & ./ELO_client_test.py 3
# ./ELO_client.py 0 & ./ELO_client.py 1 & ./ELO_client.py 2 & ./ELO_client.py 3
cd /share/elo-rating cd /share/elo-rating
python ELO_server_test.py python ELO_server_test.py
#python ELO_server.py
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment