From ae9d2f7758bb9fff139b26055aaf537a7b806202 Mon Sep 17 00:00:00 2001 From: Tilps Date: Wed, 29 Jan 2020 20:01:02 +1100 Subject: [PATCH 1/3] Bump version post release --- lc0_main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lc0_main.go b/lc0_main.go index 1e18965..54d9e5d 100644 --- a/lc0_main.go +++ b/lc0_main.go @@ -119,7 +119,7 @@ func getExtraParams() map[string]string { return map[string]string{ "user": *user, "password": *password, - "version": "24", + "version": "25", "token": strconv.Itoa(randId), "train_only": strconv.FormatBool(*trainOnly), "hostname": localHost, From ae163eea21bea96810340a5093d02bba1172b725 Mon Sep 17 00:00:00 2001 From: MerickOWA Date: Wed, 26 Feb 2020 15:07:17 -0500 Subject: [PATCH 2/3] Allow localhost name by settings or params (#104) --- lc0_main.go | 80 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 53 insertions(+), 27 deletions(-) diff --git a/lc0_main.go b/lc0_main.go index 54d9e5d..222e38b 100644 --- a/lc0_main.go +++ b/lc0_main.go @@ -46,9 +46,11 @@ var ( hasDx bool testedCudnnFp16 bool - localHost = "Unknown" + settingsPath = "settings.json" + defaultLocalHost = "Unknown" gpuType = "Unknown" + localHost = flag.String("localhost", "", "Localhost name to send to the server when reporting (defaults to Unknown, overridden by settings.json)") hostname = flag.String("hostname", "http://api.lczero.org", "Address of the server") user = flag.String("user", "", "Username") password = flag.String("password", "", "Password") @@ -71,47 +73,56 @@ var ( type Settings struct { User string Pass string + Localhost string } const inf = "inf" /* Reads the user and password from a config file and returns empty strings if anything went wrong. - If the config file does not exists, it prompts the user for a username and password and creates the config file. */ -func readSettings(path string) (string, string) { +func readSettings(path string) (string, string, string) { settings := Settings{} file, err := os.Open(path) if err != nil { // File was not found - fmt.Printf("Please enter your username and password, an account will be automatically created.\n") - fmt.Printf("Note that this password will be stored in plain text, so avoid a password that is\n") - fmt.Printf("also used for sensitive applications. It also cannot be recovered.\n") - fmt.Printf("Enter username : ") - fmt.Scanf("%s\n", &settings.User) - fmt.Printf("Enter password : ") - fmt.Scanf("%s\n", &settings.Pass) - jsonSettings, err := json.Marshal(settings) - if err != nil { - log.Fatal("Cannot encode settings to JSON ", err) - return "", "" - } - settingsFile, err := os.Create(path) - defer settingsFile.Close() - if err != nil { - log.Fatal("Could not create output file ", err) - return "", "" - } - settingsFile.Write(jsonSettings) - return settings.User, settings.Pass + return "", "", "" } defer file.Close() decoder := json.NewDecoder(file) err = decoder.Decode(&settings) if err != nil { log.Fatal("Error decoding JSON ", err) + return "", "", "" + } + return settings.User, settings.Pass, settings.Localhost +} + +/* + Prompts the user for a username and password and creates the config file. +*/ +func createSettings(path string) (string, string) { + settings := Settings{} + + fmt.Printf("Please enter your username and password, an account will be automatically created.\n") + fmt.Printf("Note that this password will be stored in plain text, so avoid a password that is\n") + fmt.Printf("also used for sensitive applications. It also cannot be recovered.\n") + fmt.Printf("Enter username : ") + fmt.Scanf("%s\n", &settings.User) + fmt.Printf("Enter password : ") + fmt.Scanf("%s\n", &settings.Pass) + jsonSettings, err := json.Marshal(settings) + if err != nil { + log.Fatal("Cannot encode settings to JSON ", err) + return "", "" + } + settingsFile, err := os.Create(path) + defer settingsFile.Close() + if err != nil { + log.Fatal("Could not create output file ", err) return "", "" } + settingsFile.Write(jsonSettings) return settings.User, settings.Pass } @@ -122,7 +133,7 @@ func getExtraParams() map[string]string { "version": "25", "token": strconv.Itoa(randId), "train_only": strconv.FormatBool(*trainOnly), - "hostname": localHost, + "hostname": *localHost, "gpu": gpuType, "gpu_id": strconv.Itoa(*gpu), } @@ -1063,8 +1074,19 @@ func main() { } log.SetFlags(log.LstdFlags | log.Lshortfile) + + settingsUser, settingsPassword, settingsHost := readSettings(settingsPath) if len(*user) == 0 || len(*password) == 0 { - *user, *password = readSettings("settings.json") + *user = settingsUser + *password = settingsPassword + + if len(*user) == 0 || len(*password) == 0 { + *user, *password = createSettings(settingsPath) + } + } + + if (len(settingsHost) != 0 && len(*localHost) == 0) { + *localHost = settingsHost } if len(*user) == 0 { @@ -1074,13 +1096,17 @@ func main() { log.Fatal("You must specify a non-empty password") } - if *report_host { + if *report_host && len(*localHost) == 0 { s, err := os.Hostname() if err == nil { - localHost = s + *localHost = s } } + if len(*localHost) == 0 { + *localHost = defaultLocalHost + } + httpClient := &http.Client{} startTime = time.Now() for i := 0; ; i++ { From 254194d24191eaa0cc71263819e760ac86223308 Mon Sep 17 00:00:00 2001 From: borg323 <39573933+borg323@users.noreply.github.com> Date: Wed, 26 Feb 2020 22:09:51 +0200 Subject: [PATCH 3/3] dx backend was renamed to dx12 (#105) --- lc0_main.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lc0_main.go b/lc0_main.go index 222e38b..91eb6fd 100644 --- a/lc0_main.go +++ b/lc0_main.go @@ -282,7 +282,7 @@ func checkLc0() { if bytes.Contains(out, []byte("blas")) { hasBlas = true } - if bytes.Contains(out, []byte("dx")) { + if bytes.Contains(out, []byte("dx12")) { hasDx = true } if bytes.Contains(out, []byte("cudnn-fp16")) { @@ -339,9 +339,9 @@ func (c *cmdWrapper) launch(networkPath string, otherNetPath string, args []stri c.Cmd.Args = append(c.Cmd.Args, fmt.Sprintf("--backend-opts=backend=cudnn%v", sGpu)) } else if hasDx { if !hasBlas { - log.Fatalf("Dx backend cannot be validated") + log.Fatalf("Dx12 backend cannot be validated") } - c.Cmd.Args = append(c.Cmd.Args, fmt.Sprintf("--backend-opts=check(freq=.01,atol=5e-1,dx%v)", sGpu)) + c.Cmd.Args = append(c.Cmd.Args, fmt.Sprintf("--backend-opts=check(freq=.01,atol=5e-1,dx12%v)", sGpu)) } else if hasOpenCL { c.Cmd.Args = append(c.Cmd.Args, fmt.Sprintf("--backend-opts=backend=opencl%v", sGpu)) } @@ -463,7 +463,7 @@ func (c *cmdWrapper) launch(networkPath string, otherNetPath string, args []stri fmt.Println(line) case strings.HasPrefix(line, "*** ERROR check failed"): fmt.Println(line) - log.Fatal("The dx backend failed the self check - try updating gpu drivers") + log.Fatal("The dx12 backend failed the self check - try updating gpu drivers") case strings.HasPrefix(line, "GPU compute capability:"): cc, _ := strconv.ParseFloat(strings.Split(line, " ")[3], 32) if cc >= 7.0 {