From d568716c2d362b22b62400459d4060ee229ed7aa Mon Sep 17 00:00:00 2001 From: borg323 Date: Thu, 5 Jul 2018 21:21:12 +0300 Subject: [PATCH 01/11] hide --lc0args option from help --- lc0_main.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lc0_main.go b/lc0_main.go index 7c525c3..f0dc5b4 100644 --- a/lc0_main.go +++ b/lc0_main.go @@ -608,9 +608,23 @@ func testEP() { } } +func hideLc0argsFlag() { + shown := new(flag.FlagSet) + flag.VisitAll(func(f *flag.Flag) { + if (f.Name != "lc0args") { + shown.Var(f.Value, f.Name, f.Usage) + } + }) + flag.Usage = func() { + fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0]) + shown.PrintDefaults() + } +} + func main() { testEP() + hideLc0argsFlag() flag.Parse() log.SetFlags(log.LstdFlags | log.Lshortfile) From a2e707e05c459fe8270132158797f2f78cb6d2c2 Mon Sep 17 00:00:00 2001 From: borg323 Date: Thu, 5 Jul 2018 21:30:43 +0300 Subject: [PATCH 02/11] introduce --backend-opts, remove --lc0args checking --- lc0_main.go | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/lc0_main.go b/lc0_main.go index f0dc5b4..c95bf05 100644 --- a/lc0_main.go +++ b/lc0_main.go @@ -38,8 +38,9 @@ var ( password = flag.String("password", "", "Password") // gpu = flag.Int("gpu", -1, "ID of the OpenCL device to use (-1 for default, or no GPU)") debug = flag.Bool("debug", false, "Enable debug mode to see verbose output and save logs") - lc0Args = flag.String("lc0args", "", - `Extra args to pass to the backend. Example: --lc0args=--backend-opts=cudnn(gpu=1)`) + lc0Args = flag.String("lc0args", "", "") + backopts = flag.String("backend-opts", "", + `Options for the lc0 mux. backend. Example: --backend-opts="cudnn(gpu=1)"`) ) // Settings holds username and password. @@ -206,26 +207,19 @@ func (c *cmdWrapper) launch(networkPath string, args []string, input bool) { c.Cmd.Args = append(c.Cmd.Args, args...) c.Cmd.Args = append(c.Cmd.Args, fmt.Sprintf("--weights=%s", networkPath)) if *lc0Args != "" { - // Strict checking of the --lc0args options to prevent someone - // from passing a different visits or batch size for example. parts := strings.Split(*lc0Args, " ") - for _, opt := range parts { - words := regexp.MustCompile("[,=().0-9]").Split(opt, -1) - for _, word := range words { - optOK := false - switch word { - case "", "--backend", "tf", "cudnn", "opencl", "blas", "cudnn-fp", - "multiplexing", "--backend-opts", "backend", "gpu", "verbose", - "true", "false", "--parallelism": - optOK = true - } - if !optOK { - log.Fatalf("Not accepted --lc0args option: %s", opt) - } + c.Cmd.Args = append(c.Cmd.Args, parts...) + } + if *backopts != "" { + // Check agains small token blacklist, currently only "random" + tokens := regexp.MustCompile("[,=().0-9]").Split(*backopts, -1) + for _, token := range tokens { + switch token { + case "random": + log.Fatalf("Not accepted in --backend-opts: %s", token) } } - - c.Cmd.Args = append(c.Cmd.Args, parts...) + c.Cmd.Args = append(c.Cmd.Args, fmt.Sprintf("--backend-opts=%s", *backopts)) } if !*debug { // c.Cmd.Args = append(c.Cmd.Args, "--quiet") From f29370e5ecc44c24939177a42fa06a643629a649 Mon Sep 17 00:00:00 2001 From: borg323 Date: Thu, 5 Jul 2018 21:47:24 +0300 Subject: [PATCH 03/11] print warning when --lc0args is used --- lc0_main.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lc0_main.go b/lc0_main.go index c95bf05..0038041 100644 --- a/lc0_main.go +++ b/lc0_main.go @@ -207,6 +207,8 @@ func (c *cmdWrapper) launch(networkPath string, args []string, input bool) { c.Cmd.Args = append(c.Cmd.Args, args...) c.Cmd.Args = append(c.Cmd.Args, fmt.Sprintf("--weights=%s", networkPath)) if *lc0Args != "" { + log.Println("WARNING: Option --lc0args is for testing, not production use!") + log.SetPrefix("TESTING: ") parts := strings.Split(*lc0Args, " ") c.Cmd.Args = append(c.Cmd.Args, parts...) } From 676c2143fcb55701f5bc91501d2d217a17aeefc9 Mon Sep 17 00:00:00 2001 From: borg323 Date: Thu, 5 Jul 2018 22:08:42 +0300 Subject: [PATCH 04/11] move server controled parameters to end of command --- lc0_main.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lc0_main.go b/lc0_main.go index 0038041..0af1679 100644 --- a/lc0_main.go +++ b/lc0_main.go @@ -204,8 +204,9 @@ func createCmdWrapper() *cmdWrapper { func (c *cmdWrapper) launch(networkPath string, args []string, input bool) { dir, _ := os.Getwd() c.Cmd = exec.Command(path.Join(dir, "lc0")) - c.Cmd.Args = append(c.Cmd.Args, args...) - c.Cmd.Args = append(c.Cmd.Args, fmt.Sprintf("--weights=%s", networkPath)) + // Add the "selfplay" or "uci" part first + c.Cmd.Args = append(c.Cmd.Args, args[0]) + args = args[1:] if *lc0Args != "" { log.Println("WARNING: Option --lc0args is for testing, not production use!") log.SetPrefix("TESTING: ") @@ -223,6 +224,8 @@ func (c *cmdWrapper) launch(networkPath string, args []string, input bool) { } c.Cmd.Args = append(c.Cmd.Args, fmt.Sprintf("--backend-opts=%s", *backopts)) } + c.Cmd.Args = append(c.Cmd.Args, args...) + c.Cmd.Args = append(c.Cmd.Args, fmt.Sprintf("--weights=%s", networkPath)) if !*debug { // c.Cmd.Args = append(c.Cmd.Args, "--quiet") fmt.Println("lc0 is never quiet.") From 8cbaa58173382ad460ddd3456304d19b7719c15b Mon Sep 17 00:00:00 2001 From: borg323 Date: Fri, 6 Jul 2018 01:37:19 +0300 Subject: [PATCH 05/11] add --parallelism option --- lc0_main.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lc0_main.go b/lc0_main.go index 0af1679..b6f1206 100644 --- a/lc0_main.go +++ b/lc0_main.go @@ -41,6 +41,7 @@ var ( lc0Args = flag.String("lc0args", "", "") backopts = flag.String("backend-opts", "", `Options for the lc0 mux. backend. Example: --backend-opts="cudnn(gpu=1)"`) + parallel = flag.Int("parallelism", -1, "Number of games to play in parallel (-1 for default)") ) // Settings holds username and password. @@ -205,7 +206,8 @@ func (c *cmdWrapper) launch(networkPath string, args []string, input bool) { dir, _ := os.Getwd() c.Cmd = exec.Command(path.Join(dir, "lc0")) // Add the "selfplay" or "uci" part first - c.Cmd.Args = append(c.Cmd.Args, args[0]) + mode := args[0] + c.Cmd.Args = append(c.Cmd.Args, mode) args = args[1:] if *lc0Args != "" { log.Println("WARNING: Option --lc0args is for testing, not production use!") @@ -224,6 +226,9 @@ func (c *cmdWrapper) launch(networkPath string, args []string, input bool) { } c.Cmd.Args = append(c.Cmd.Args, fmt.Sprintf("--backend-opts=%s", *backopts)) } + if *parallel != -1 && mode == "selfplay" { + c.Cmd.Args = append(c.Cmd.Args, fmt.Sprintf("--parallelism=%v", *parallel)) + } c.Cmd.Args = append(c.Cmd.Args, args...) c.Cmd.Args = append(c.Cmd.Args, fmt.Sprintf("--weights=%s", networkPath)) if !*debug { From 5f9e768db8f46531ec0551bfbad67bb8c8c2428c Mon Sep 17 00:00:00 2001 From: borg323 Date: Thu, 12 Jul 2018 01:38:41 +0300 Subject: [PATCH 06/11] requested change --- lc0_main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lc0_main.go b/lc0_main.go index b6f1206..de25eaa 100644 --- a/lc0_main.go +++ b/lc0_main.go @@ -226,7 +226,7 @@ func (c *cmdWrapper) launch(networkPath string, args []string, input bool) { } c.Cmd.Args = append(c.Cmd.Args, fmt.Sprintf("--backend-opts=%s", *backopts)) } - if *parallel != -1 && mode == "selfplay" { + if *parallel > 0 && mode == "selfplay" { c.Cmd.Args = append(c.Cmd.Args, fmt.Sprintf("--parallelism=%v", *parallel)) } c.Cmd.Args = append(c.Cmd.Args, args...) From ffc31a96f35c9f37664c630e48fe439624259023 Mon Sep 17 00:00:00 2001 From: Tilps Date: Thu, 19 Jul 2018 21:05:43 +1000 Subject: [PATCH 07/11] Force match play to use multiplex backend to match selfplay so backend-opts apply evenly (#32) * Force match play to use multiplex backend * Fix typo. --- lc0_main.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lc0_main.go b/lc0_main.go index de25eaa..07ad4ea 100644 --- a/lc0_main.go +++ b/lc0_main.go @@ -209,6 +209,9 @@ func (c *cmdWrapper) launch(networkPath string, args []string, input bool) { mode := args[0] c.Cmd.Args = append(c.Cmd.Args, mode) args = args[1:] + if mode != "selfplay" { + c.Cmd.Args = append(c.Cmd.Args, "--backend=multiplexing") + } if *lc0Args != "" { log.Println("WARNING: Option --lc0args is for testing, not production use!") log.SetPrefix("TESTING: ") From 7a821b8d953b3b18f37b6c648926c685f79890e3 Mon Sep 17 00:00:00 2001 From: Tilps Date: Sun, 29 Jul 2018 11:03:11 +1000 Subject: [PATCH 08/11] Remove any partial download on download failure. (#34) --- lc0_main.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lc0_main.go b/lc0_main.go index 07ad4ea..5bfa839 100644 --- a/lc0_main.go +++ b/lc0_main.go @@ -507,6 +507,8 @@ func getNetwork(httpClient *http.Client, sha string, clearOld bool) (string, err // Otherwise, let's download it err := client.DownloadNetwork(httpClient, *hostname, path, sha) if err != nil { + // Ensure there is no remnant after a failed download. + os.Remove(path) log.Printf("Network download failed: %v", err) return "", err } From 0e9022df0c14fec62c6381729a87c943b4b999e6 Mon Sep 17 00:00:00 2001 From: Tilps Date: Thu, 2 Aug 2018 17:13:06 +1000 Subject: [PATCH 09/11] Change lc0_main.go default server to main (#31) * Change lc0_main.go default server to main * Switch from IP address to api.lczero.org --- lc0_main.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lc0_main.go b/lc0_main.go index 5bfa839..dca50b3 100644 --- a/lc0_main.go +++ b/lc0_main.go @@ -33,7 +33,7 @@ var ( totalGames int pendingNextGame *client.NextGameResponse - hostname = flag.String("hostname", "http://testserver.lczero.org", "Address of the server") + hostname = flag.String("hostname", "http://api.lczero.org", "Address of the server") user = flag.String("user", "", "Username") password = flag.String("password", "", "Password") // gpu = flag.Int("gpu", -1, "ID of the OpenCL device to use (-1 for default, or no GPU)") @@ -42,6 +42,7 @@ var ( backopts = flag.String("backend-opts", "", `Options for the lc0 mux. backend. Example: --backend-opts="cudnn(gpu=1)"`) parallel = flag.Int("parallelism", -1, "Number of games to play in parallel (-1 for default)") + useTestServer = flag.Bool("use-test-server", false, "Set host name to test server.") ) // Settings holds username and password. @@ -636,6 +637,10 @@ func main() { hideLc0argsFlag() flag.Parse() + if *useTestServer { + *hostname = "http://testserver.lczero.org" + } + log.SetFlags(log.LstdFlags | log.Lshortfile) if len(*user) == 0 || len(*password) == 0 { *user, *password = readSettings("settings.json") From b30fb50a1c8a998a1da205d16478f28068d1ae53 Mon Sep 17 00:00:00 2001 From: Tilps Date: Thu, 2 Aug 2018 17:31:43 +1000 Subject: [PATCH 10/11] Bump version to 16 for lc0_main.go --- lc0_main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lc0_main.go b/lc0_main.go index dca50b3..b81727f 100644 --- a/lc0_main.go +++ b/lc0_main.go @@ -95,7 +95,7 @@ func getExtraParams() map[string]string { return map[string]string{ "user": *user, "password": *password, - "version": "15", + "version": "16", } } From 7493018e7313050ad7a3f41a6e93b22be88ee7d1 Mon Sep 17 00:00:00 2001 From: borg323 <39573933+borg323@users.noreply.github.com> Date: Thu, 2 Aug 2018 11:40:48 +0300 Subject: [PATCH 11/11] Appveyor builds for all client and deloyment on releases (#36) * Appveyor builds for all client and deloyment on releases * Fix path --- appveyor.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 appveyor.yml diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..84e6b43 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,28 @@ +version: "{build}" +platform: x64 +clone_folder: c:\gopath\src\github.com\LeelaChessZero\lczero-client + +environment: + GOPATH: c:\gopath;c:\gopath\src\github.com\LeelaChessZero\lczero-client\ + matrix: + - NAME: .exe + GOOS: windows + - NAME: _linux + GOOS: linux + - NAME: _mac + GOOS: darwin +install: + - go get -u github.com/Tilps/chess +build_script: + - go build -o client%NAME% lc0_main.go +artifacts: + - path: client$(NAME) + name: client +deploy: + - provider: GitHub + artifact: client%NAME% + auth_token: + secure: USFAdwQKTXqOXQjCYQfzWvzRpUhvqJLBkN4hbOg+j876vDxGZHt9bMYayb5evePp + on: + appveyor_repo_tag: true +