46
46
hasDx bool
47
47
testedCudnnFp16 bool
48
48
49
- localHost = "Unknown"
49
+ settingsPath = "settings.json"
50
+ defaultLocalHost = "Unknown"
50
51
gpuType = "Unknown"
51
52
53
+ localHost = flag .String ("localhost" , "" , "Localhost name to send to the server when reporting (defaults to Unknown, overridden by settings.json)" )
52
54
hostname = flag .String ("hostname" , "http://api.lczero.org" , "Address of the server" )
53
55
user = flag .String ("user" , "" , "Username" )
54
56
password = flag .String ("password" , "" , "Password" )
@@ -71,58 +73,67 @@ var (
71
73
type Settings struct {
72
74
User string
73
75
Pass string
76
+ Localhost string
74
77
}
75
78
76
79
const inf = "inf"
77
80
78
81
/*
79
82
Reads the user and password from a config file and returns empty strings if anything went wrong.
80
- If the config file does not exists, it prompts the user for a username and password and creates the config file.
81
83
*/
82
- func readSettings (path string ) (string , string ) {
84
+ func readSettings (path string ) (string , string , string ) {
83
85
settings := Settings {}
84
86
file , err := os .Open (path )
85
87
if err != nil {
86
88
// File was not found
87
- fmt .Printf ("Please enter your username and password, an account will be automatically created.\n " )
88
- fmt .Printf ("Note that this password will be stored in plain text, so avoid a password that is\n " )
89
- fmt .Printf ("also used for sensitive applications. It also cannot be recovered.\n " )
90
- fmt .Printf ("Enter username : " )
91
- fmt .Scanf ("%s\n " , & settings .User )
92
- fmt .Printf ("Enter password : " )
93
- fmt .Scanf ("%s\n " , & settings .Pass )
94
- jsonSettings , err := json .Marshal (settings )
95
- if err != nil {
96
- log .Fatal ("Cannot encode settings to JSON " , err )
97
- return "" , ""
98
- }
99
- settingsFile , err := os .Create (path )
100
- defer settingsFile .Close ()
101
- if err != nil {
102
- log .Fatal ("Could not create output file " , err )
103
- return "" , ""
104
- }
105
- settingsFile .Write (jsonSettings )
106
- return settings .User , settings .Pass
89
+ return "" , "" , ""
107
90
}
108
91
defer file .Close ()
109
92
decoder := json .NewDecoder (file )
110
93
err = decoder .Decode (& settings )
111
94
if err != nil {
112
95
log .Fatal ("Error decoding JSON " , err )
96
+ return "" , "" , ""
97
+ }
98
+ return settings .User , settings .Pass , settings .Localhost
99
+ }
100
+
101
+ /*
102
+ Prompts the user for a username and password and creates the config file.
103
+ */
104
+ func createSettings (path string ) (string , string ) {
105
+ settings := Settings {}
106
+
107
+ fmt .Printf ("Please enter your username and password, an account will be automatically created.\n " )
108
+ fmt .Printf ("Note that this password will be stored in plain text, so avoid a password that is\n " )
109
+ fmt .Printf ("also used for sensitive applications. It also cannot be recovered.\n " )
110
+ fmt .Printf ("Enter username : " )
111
+ fmt .Scanf ("%s\n " , & settings .User )
112
+ fmt .Printf ("Enter password : " )
113
+ fmt .Scanf ("%s\n " , & settings .Pass )
114
+ jsonSettings , err := json .Marshal (settings )
115
+ if err != nil {
116
+ log .Fatal ("Cannot encode settings to JSON " , err )
117
+ return "" , ""
118
+ }
119
+ settingsFile , err := os .Create (path )
120
+ defer settingsFile .Close ()
121
+ if err != nil {
122
+ log .Fatal ("Could not create output file " , err )
113
123
return "" , ""
114
124
}
125
+ settingsFile .Write (jsonSettings )
115
126
return settings .User , settings .Pass
116
127
}
117
128
118
129
func getExtraParams () map [string ]string {
119
130
return map [string ]string {
120
131
"user" : * user ,
121
132
"password" : * password ,
122
- "version" : "24 " ,
133
+ "version" : "25 " ,
123
134
"token" : strconv .Itoa (randId ),
124
135
"train_only" : strconv .FormatBool (* trainOnly ),
125
- "hostname" : localHost ,
136
+ "hostname" : * localHost ,
126
137
"gpu" : gpuType ,
127
138
"gpu_id" : strconv .Itoa (* gpu ),
128
139
}
@@ -271,7 +282,7 @@ func checkLc0() {
271
282
if bytes .Contains (out , []byte ("blas" )) {
272
283
hasBlas = true
273
284
}
274
- if bytes .Contains (out , []byte ("dx " )) {
285
+ if bytes .Contains (out , []byte ("dx12 " )) {
275
286
hasDx = true
276
287
}
277
288
if bytes .Contains (out , []byte ("cudnn-fp16" )) {
@@ -328,9 +339,9 @@ func (c *cmdWrapper) launch(networkPath string, otherNetPath string, args []stri
328
339
c .Cmd .Args = append (c .Cmd .Args , fmt .Sprintf ("--backend-opts=backend=cudnn%v" , sGpu ))
329
340
} else if hasDx {
330
341
if ! hasBlas {
331
- log .Fatalf ("Dx backend cannot be validated" )
342
+ log .Fatalf ("Dx12 backend cannot be validated" )
332
343
}
333
- c .Cmd .Args = append (c .Cmd .Args , fmt .Sprintf ("--backend-opts=check(freq=.01,atol=5e-1,dx %v)" , sGpu ))
344
+ c .Cmd .Args = append (c .Cmd .Args , fmt .Sprintf ("--backend-opts=check(freq=.01,atol=5e-1,dx12 %v)" , sGpu ))
334
345
} else if hasOpenCL {
335
346
c .Cmd .Args = append (c .Cmd .Args , fmt .Sprintf ("--backend-opts=backend=opencl%v" , sGpu ))
336
347
}
@@ -452,7 +463,7 @@ func (c *cmdWrapper) launch(networkPath string, otherNetPath string, args []stri
452
463
fmt .Println (line )
453
464
case strings .HasPrefix (line , "*** ERROR check failed" ):
454
465
fmt .Println (line )
455
- log .Fatal ("The dx backend failed the self check - try updating gpu drivers" )
466
+ log .Fatal ("The dx12 backend failed the self check - try updating gpu drivers" )
456
467
case strings .HasPrefix (line , "GPU compute capability:" ):
457
468
cc , _ := strconv .ParseFloat (strings .Split (line , " " )[3 ], 32 )
458
469
if cc >= 7.0 {
@@ -1063,8 +1074,19 @@ func main() {
1063
1074
}
1064
1075
1065
1076
log .SetFlags (log .LstdFlags | log .Lshortfile )
1077
+
1078
+ settingsUser , settingsPassword , settingsHost := readSettings (settingsPath )
1066
1079
if len (* user ) == 0 || len (* password ) == 0 {
1067
- * user , * password = readSettings ("settings.json" )
1080
+ * user = settingsUser
1081
+ * password = settingsPassword
1082
+
1083
+ if len (* user ) == 0 || len (* password ) == 0 {
1084
+ * user , * password = createSettings (settingsPath )
1085
+ }
1086
+ }
1087
+
1088
+ if (len (settingsHost ) != 0 && len (* localHost ) == 0 ) {
1089
+ * localHost = settingsHost
1068
1090
}
1069
1091
1070
1092
if len (* user ) == 0 {
@@ -1074,13 +1096,17 @@ func main() {
1074
1096
log .Fatal ("You must specify a non-empty password" )
1075
1097
}
1076
1098
1077
- if * report_host {
1099
+ if * report_host && len ( * localHost ) == 0 {
1078
1100
s , err := os .Hostname ()
1079
1101
if err == nil {
1080
- localHost = s
1102
+ * localHost = s
1081
1103
}
1082
1104
}
1083
1105
1106
+ if len (* localHost ) == 0 {
1107
+ * localHost = defaultLocalHost
1108
+ }
1109
+
1084
1110
httpClient := & http.Client {}
1085
1111
startTime = time .Now ()
1086
1112
for i := 0 ; ; i ++ {
0 commit comments