NeymarL / ChineseChess-AlphaZero

Implement AlphaZero/AlphaGo Zero methods on Chinese chess.
https://cczero.org
GNU General Public License v3.0
1.09k stars 344 forks source link

mac selfplay 每步很慢,需要几十秒 #33

Closed reneix closed 5 years ago

reneix commented 6 years ago

mac 10.13.3 python run.py --type distribute --distributed self

distribute.py: class PlayConfig: def init(self): self.max_processes = 1 # tune this to your cpu cores self.search_threads = 10 # increase this will be faster but with weaker performance

agent/player.py line 179: self.all_done.acquire(True) 发现这里每次调用时间很长,几百ms。 去掉该调用之后,发现以下错误。走几步之后程序会退出。

2018-12-03 18:30:51,787@cchess_alphazero.worker.self_play MainThread ERROR # No chessman in 0010, state = rkemsmer1/9/1c5c1/p1p1p1p1p/9/9/P1P1P1P1P/1C5C1/9/1REMSMEKR, no_act = [], policy = [nan, ... nan]

请问这个all_done.acquire 是用来同步 MCTS_search 搜索状态的么?

NeymarL commented 6 years ago

是的。Mac很慢是正常的,因为只能用CPU来跑。

reneix commented 6 years ago

agent/player.py line 179: self.all_done.acquire(True) 发现这里每次调用时间很长,几百ms。

这个加锁是在循环里面调用的,没有看到release,求问这个是用来同步什么状态的么?

NeymarL commented 6 years ago

release在这里,保证这一批搜索都结束再开始下一批。 https://github.com/NeymarL/ChineseChess-AlphaZero/blob/eab27f28fb7371ad15508fd433857af4e257b347/cchess_alphazero/agent/player.py#L370-L374

reneix commented 6 years ago

thx,我学习一下