engine error

This commit is contained in:
Sander Land committed 2020-05-06 16:51:35 +02:00
1 parent e0d800895f
commit b33b7b33e3
6 files changed
+102 -8

No files matched your search

+3 -3
View File
@@ -55,14 +55,14 @@ maxVisits = 500
# number of visits, and thread contention will reduce efficiency, so cross-position parallelization is preferable # number of visits, and thread contention will reduce efficiency, so cross-position parallelization is preferable
# to numSearchThreads, but numSearchThreads is preferable if you want to reduce latency, and have individual # to numSearchThreads, but numSearchThreads is preferable if you want to reduce latency, and have individual
# searches complete faster by doing fewer of them at a time. # searches complete faster by doing fewer of them at a time.
numSearchThreads = 2 numSearchThreads = 6
# GPU Settings------------------------------------------------------------------------------- # GPU Settings-------------------------------------------------------------------------------
# Maximum number of positions to send to GPU at once. # Maximum number of positions to send to GPU at once.
nnMaxBatchSize = 128 nnMaxBatchSize = 64
# Cache up to 2 ** this many neural net evaluations in case of transpositions in the tree. # Cache up to 2 ** this many neural net evaluations in case of transpositions in the tree.
nnCacheSizePowerOfTwo = 23 nnCacheSizePowerOfTwo = 21
# Size of mutex pool for nnCache is 2 ** this # Size of mutex pool for nnCache is 2 ** this
nnMutexPoolSizePowerOfTwo = 17 nnMutexPoolSizePowerOfTwo = 17
# Randomize board orientation when running neural net evals? # Randomize board orientation when running neural net evals?
+3 -1
View File
@@ -1,5 +1,6 @@
bot_strategy_names = { bot_strategy_names = {
"dev": "P:Noise", "dev": "P:Noise",
"dev-beta": "P:Weighted",
"strong": "Policy", "strong": "Policy",
"influence": "P:Influence", "influence": "P:Influence",
"territory": "P:Territory", "territory": "P:Territory",
@@ -11,7 +12,8 @@ bot_strategy_names = {
greetings = { greetings = {
"dev": "Experimental!", "dev": "Policy+Dirichlet noise.",
"dev-beta": "Play a policy-weighted move.",
"strong": "Play top policy move.", "strong": "Play top policy move.",
"influence": "Play an influential style.", "influence": "Play an influential style.",
"territory": "Play a territorial style.", "territory": "Play a territorial style.",
+5 -2
View File
@@ -15,7 +15,10 @@ if True or bot in ["dev", "local"]:
else: else:
GTP2OGS = "node ../stable-gtp2ogs" GTP2OGS = "node ../stable-gtp2ogs"
BOT_SETTINGS = f" --maxconnectedgames {MAXGAMES} --maxhandicapunranked 25 --maxhandicapranked 1 --boardsizesranked 19 --boardsizesunranked all --komisranked automatic,5.5,6.5,7.5 --komisunranked all" BOT_SETTINGS = f" --maxconnectedgames {MAXGAMES} --maxhandicapunranked 25 --maxhandicapranked 1 --boardsizesranked 19 --boardsizesunranked all --komisranked automatic,5.5,6.5,7.5 --komisunranked all"
if 'beta' in bot:
BOT_SETTINGS += " --beta"
else:
BOT_SETTINGS += " --rankedonly"
username = f"katrain-{bot}" username = f"katrain-{bot}"
@@ -40,6 +43,6 @@ if settings:
GREETING += f" Settings: {settings_dump}." GREETING += f" Settings: {settings_dump}."
BYEMSG = "Thank you for playing. If you have any feedback, please message my admin! Play with these bots at any time by downloading KaTrain at github.com/sanderland/katrain" BYEMSG = "Thank you for playing. If you have any feedback, please message my admin! Play with these bots at any time by downloading KaTrain at github.com/sanderland/katrain"
cmd = f'{GTP2OGS} --debug --apikey {APIKEY} --username {username} --greeting "{GREETING}" --farewell "{BYEMSG}" {BOT_SETTINGS} --farewellscore --aichat --noclock --nopause --speeds blitz,live --persist --minrank 25k -- python bots/ai2gtp.py {bot} {port}' cmd = f'{GTP2OGS} --debug --apikey {APIKEY} --rejectnewfile ~/shutdown_bots --username {username} --greeting "{GREETING}" --farewell "{BYEMSG}" {BOT_SETTINGS} --farewellscore --aichat --noclock --nopause --speeds blitz,live --persist --minrank 25k -- python bots/ai2gtp.py {bot} {port}'
print(f"starting bot {username} using server port {port} --> {cmd}") print(f"starting bot {username} using server port {port} --> {cmd}")
os.system(cmd) os.system(cmd)
+2 -2
View File
@@ -43,9 +43,9 @@ class KataGoEngine:
try: try:
self.katrain.log(f"Starting KataGo with {self.command}", OUTPUT_DEBUG) self.katrain.log(f"Starting KataGo with {self.command}", OUTPUT_DEBUG)
self.katago_process = subprocess.Popen(self.command, stdin=subprocess.PIPE, stdout=subprocess.PIPE) self.katago_process = subprocess.Popen(self.command, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
except FileNotFoundError: except FileNotFoundError as e:
self.katrain.log( self.katrain.log(
f"Starting kata with command '{self.command}' failed. If you are on Mac or Linux, please change the settings or configuration file (config.json) to point to the correct KataGo executable.", f"Starting kata with command '{self.command}' failed with error {e}. Please make sure the 'katago' value under 'engine' in settings points to the correct KataGo executable.",
OUTPUT_ERROR, OUTPUT_ERROR,
) )
+42
View File
@@ -0,0 +1,42 @@
# This is a stand-alone script that generates a review for an SGF
import json
import sys
import time
from core.common import OUTPUT_INFO
from core.engine import KataGoEngine
from core.game import Game, KaTrainSGF
if len(sys.argv) < 2:
exit(1)
inputfile = sys.argv[1]
with open("config.json") as f:
settings = json.load(f)
sgf_settings = settings["sgf"]
engine_settings = settings["engine"]
game_settings = settings["game"]
trainer_settings = settings["trainer"]
#engine_settings['threads'] = 32
engine_settings["max_time"] = 1000
class Logger:
def log(self, msg, level):
if level <= OUTPUT_INFO:
print(msg)
logger = Logger()
engine = KataGoEngine(logger, engine_settings)
move_tree = KaTrainSGF.parse_file(inputfile)
game = Game(logger, engine, game_settings, move_tree=None, analyze_fast=True)
game.root=move_tree
reverse_nodes = game.root.nodes_in_tree[::-1]
for n in reverse_nodes[::10]:
n.analyze(engine=engine)
while not n.analysis_ready:
time.sleep(0.01)
print(n.single_move,'done')
+47
View File
@@ -0,0 +1,47 @@
# This is a stand-alone script that generates a review for an SGF
import json
import sys
import time
from core.common import OUTPUT_INFO
from core.engine import KataGoEngine
from core.game import Game, KaTrainSGF
if len(sys.argv) < 2:
exit(1)
inputfile = sys.argv[1]
with open("config.json") as f:
settings = json.load(f)
sgf_settings = settings["sgf"]
engine_settings = settings["engine"]
game_settings = settings["game"]
trainer_settings = settings["trainer"]
#engine_settings['threads'] = 32
engine_settings["max_time"] = 1000
class Logger:
def log(self, msg, level):
if level <= OUTPUT_INFO:
print(msg)
logger = Logger()
engine = KataGoEngine(logger, engine_settings)
move_tree = KaTrainSGF.parse_file(inputfile)
game = Game(logger, engine, game_settings, move_tree=move_tree, analyze_fast=False)
nodes = game.root.nodes_in_tree
remaining = len(nodes)
while remaining > 0:
remaining = sum(not n.analysis_ready for n in nodes)
print(f"Waiting for {remaining} queries")
time.sleep(0.1)
msg = game.write_sgf(
sgf_settings["sgf_save"],
trainer_config=trainer_settings,
save_feedback=sgf_settings["save_feedback"],
eval_thresholds=trainer_settings["eval_thresholds"],
)