Nnictl.md 21.4 KB
Newer Older
Chi Song's avatar
Chi Song committed
1
2
3
4
5
6
7
8
9
10
11
12
# nnictl

## 介绍

**nnictl** 是一个命令行工具,用来控制 NNI Experiment,如启动、停止、继续 Experiment,启动、停止 NNIBoard 等等。

## 命令

nnictl 支持的命令:

* [nnictl create](#create)
* [nnictl resume](#resume)
Chi Song's avatar
Chi Song committed
13
* [nnictl view](#view)
Chi Song's avatar
Chi Song committed
14
15
16
17
* [nnictl stop](#stop)
* [nnictl update](#update)
* [nnictl trial](#trial)
* [nnictl top](#top)
18
* [nnictl experiment](#experiment)
Chi Song's avatar
Chi Song committed
19
* [nnictl platform](#platform)
Chi Song's avatar
Chi Song committed
20
21
22
23
24
* [nnictl config](#config)
* [nnictl log](#log)
* [nnictl webui](#webui)
* [nnictl tensorboard](#tensorboard)
* [nnictl package](#package)
Chi Song's avatar
Chi Song committed
25
* [nnictl ss_gen](#ss_gen)
Chi Song's avatar
Chi Song committed
26
27
28
29
30
* [nnictl --version](#version)

### 管理 Experiment

<a name="create"></a>
Chi Song's avatar
Chi Song committed
31
32

### nnictl create
Chi Song's avatar
Chi Song committed
33

Chi Song's avatar
Chi Song committed
34
* 说明
Chi Song's avatar
Chi Song committed
35
  
Chi Song's avatar
Chi Song committed
36
  此命令使用参数中的配置文件,来创建新的 Experiment。
Chi Song's avatar
Chi Song committed
37
  
Chi Song's avatar
Chi Song committed
38
39
40
  此命令成功完成后,上下文会被设置为此 Experiment。这意味着如果不显式改变上下文(暂不支持),输入的以下命令,都作用于此 Experiment。

* 用法
Chi Song's avatar
Chi Song committed
41
  
Chi Song's avatar
Chi Song committed
42
43
44
45
46
  ```bash
  nnictl create [OPTIONS]
  ```

* 选项
Chi Song's avatar
Chi Song committed
47
  
Chi Song's avatar
Chi Song committed
48
49
50
51
52
53
  | 参数及缩写            | 是否必需  | 默认值 | 说明                     |
  | ---------------- | ----- | --- | ---------------------- |
  | --config, -c     | True  |     | Experiment 的 YAML 配置文件 |
  | --port, -p       | False |     | RESTful 服务的端口          |
  | --debug, -d      | False |     | 设置为调试模式                |
  | --foreground, -f | False |     | 设为前台运行模式,将日志输出到终端      |
Chi Song's avatar
Chi Song committed
54

Chi Song's avatar
Chi Song committed
55
* 示例
Chi Song's avatar
Chi Song committed
56
57
  
  > 在默认端口 8080 上创建一个新的 Experiment
Chi Song's avatar
Chi Song committed
58
  
Chi Song's avatar
Chi Song committed
59
  ```bash
Chi Song's avatar
Chi Song committed
60
  nnictl create --config nni/examples/trials/mnist-tfv1/config.yml
Chi Song's avatar
Chi Song committed
61
  ```
Chi Song's avatar
Chi Song committed
62
  
Chi Song's avatar
Chi Song committed
63
64
65
  > 在指定的端口 8088 上创建新的 Experiment
  
  ```bash
Chi Song's avatar
Chi Song committed
66
  nnictl create --config nni/examples/trials/mnist-tfv1/config.yml --port 8088
Chi Song's avatar
Chi Song committed
67
68
69
70
71
  ```
  
  > 在指定的端口 8088 上创建新的 Experiment,并启用调试模式
  
  ```bash
Chi Song's avatar
Chi Song committed
72
  nnictl create --config nni/examples/trials/mnist-tfv1/config.yml --port 8088 --debug
Chi Song's avatar
Chi Song committed
73
74
75
76
77
78
79
  ```

注意:

```text
调试模式会禁用 Trialkeeper 中的版本校验功能。
```
Chi Song's avatar
Chi Song committed
80
81
82

<a name="resume"></a>

Chi Song's avatar
Chi Song committed
83
### nnictl resume
Chi Song's avatar
Chi Song committed
84
85

* 说明
Chi Song's avatar
Chi Song committed
86
  
Chi Song's avatar
Chi Song committed
87
88
89
  使用此命令恢复已停止的 Experiment。

* 用法
Chi Song's avatar
Chi Song committed
90
  
Chi Song's avatar
Chi Song committed
91
92
93
94
95
  ```bash
  nnictl resume [OPTIONS]
  ```

* 选项
Chi Song's avatar
Chi Song committed
96
  
Chi Song's avatar
Chi Song committed
97
98
99
100
101
102
  | 参数及缩写            | 是否必需  | 默认值 | 说明                               |
  | ---------------- | ----- | --- | -------------------------------- |
  | id               | True  |     | 要恢复的 Experiment 标识               |
  | --port, -p       | False |     | 要恢复的 Experiment 使用的 RESTful 服务端口 |
  | --debug, -d      | False |     | 设置为调试模式                          |
  | --foreground, -f | False |     | 设为前台运行模式,将日志输出到终端                |
Chi Song's avatar
Chi Song committed
103

Chi Song's avatar
Chi Song committed
104
* 示例
Chi Song's avatar
Chi Song committed
105
106
107
108
109
110
111
  
  > 在指定的端口 8088 上恢复 Experiment
  
  ```bash
  nnictl resume [experiment_id] --port 8088
  ```

Chi Song's avatar
Chi Song committed
112
113
<a name="view"></a>

Chi Song's avatar
Chi Song committed
114
### nnictl view
Chi Song's avatar
Chi Song committed
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140

* 说明
  
  使用此命令查看已停止的 Experiment。

* 用法
  
  ```bash
  nnictl view [OPTIONS]
  ```

* 选项
  
  | 参数及缩写      | 是否必需  | 默认值 | 说明                               |
  | ---------- | ----- | --- | -------------------------------- |
  | id         | True  |     | 要查看的 Experiment 标识               |
  | --port, -p | False |     | 要查看的 Experiment 使用的 RESTful 服务端口 |

* 示例
  
  > 在指定的端口 8088 上查看 Experiment
  
  ```bash
  nnictl view [experiment_id] --port 8088
  ```

Chi Song's avatar
Chi Song committed
141
<a name="stop"></a>
Chi Song's avatar
Chi Song committed
142
143

### nnictl stop
Chi Song's avatar
Chi Song committed
144

Chi Song's avatar
Chi Song committed
145
* 说明
Chi Song's avatar
Chi Song committed
146
  
Chi Song's avatar
Chi Song committed
147
148
149
  使用此命令来停止正在运行的单个或多个 Experiment。

* 用法
Chi Song's avatar
Chi Song committed
150
  
Chi Song's avatar
Chi Song committed
151
  ```bash
Chi Song's avatar
Chi Song committed
152
  nnictl stop [Options]
Chi Song's avatar
Chi Song committed
153
154
  ```

155
* 选项
Chi Song's avatar
Chi Song committed
156
157
158
159
160
  
  | 参数及缩写      | 是否必需  | 默认值 | 说明                               |
  | ---------- | ----- | --- | -------------------------------- |
  | id         | False |     | 要停止的 Experiment 标识               |
  | --port, -p | False |     | 要停止的 Experiment 使用的 RESTful 服务端口 |
Chi Song's avatar
Chi Song committed
161
  | --all, -a  | False |     | 停止所有 Experiment                  |
162

Chi Song's avatar
Chi Song committed
163
* 详细信息及示例
Chi Song's avatar
Chi Song committed
164
165
  
  1. 如果没有指定 id,并且当前有运行的 Experiment,则会停止该 Experiment,否则会输出错误信息。
Chi Song's avatar
Chi Song committed
166
    
Chi Song's avatar
Chi Song committed
167
168
169
170
        ```bash
        nnictl stop
        ```
        
Chi Song's avatar
Chi Song committed
171
  
Chi Song's avatar
Chi Song committed
172
  2. 如果指定了 id,并且此 id 匹配正在运行的 Experiment,nnictl 会停止相应的 Experiment,否则会输出错误信息。
Chi Song's avatar
Chi Song committed
173
    
Chi Song's avatar
Chi Song committed
174
175
176
        ```bash
        nnictl stop [experiment_id]
        ```
Chi Song's avatar
Chi Song committed
177
178
179
180
        
  
  3. 如果指定了端口,并且此端口有正在运行的 Experiment,则会停止此 Experiment。
    
181
182
        ```bash
        nnictl stop --port 8080
Chi Song's avatar
Chi Song committed
183
184
185
        ```
        
  
Chi Song's avatar
Chi Song committed
186
  4. 可使用 'nnictl stop --all' 来停止所有的 Experiment。
Chi Song's avatar
Chi Song committed
187
    
Chi Song's avatar
Chi Song committed
188
        ```bash
Chi Song's avatar
Chi Song committed
189
        nnictl stop --all
Chi Song's avatar
Chi Song committed
190
191
192
        ```
        
  
193
  5. 如果 id 以 * 结尾,nnictl 会停止所有匹配此通配符的 Experiment。
Chi Song's avatar
Chi Song committed
194
  
195
196
  6. 如果 id 不存在,但匹配了某个Experiment 的 id 前缀,nnictl 会停止匹配的Experiment 。
  7. 如果 id 不存在,但匹配了多个 Experiment id 的前缀,nnictl 会输出这些 id 的信息。
Chi Song's avatar
Chi Song committed
197
198
199

<a name="update"></a>

Chi Song's avatar
Chi Song committed
200
### nnictl update
Chi Song's avatar
Chi Song committed
201
202

* **nnictl update searchspace**
Chi Song's avatar
Chi Song committed
203
  
Chi Song's avatar
Chi Song committed
204
  * 说明
Chi Song's avatar
Chi Song committed
205
    
Chi Song's avatar
Chi Song committed
206
207
208
    可以用此命令来更新 Experiment 的搜索空间。
  
  * 用法
Chi Song's avatar
Chi Song committed
209
    
Chi Song's avatar
Chi Song committed
210
211
212
213
214
    ```bash
    nnictl update searchspace [OPTIONS]
    ```
  
  * 选项
Chi Song's avatar
Chi Song committed
215
216
217
218
219
220
  
  | 参数及缩写          | 是否必需  | 默认值 | 说明                    |
  | -------------- | ----- | --- | --------------------- |
  | id             | False |     | 需要设置的 Experiment 的 id |
  | --filename, -f | True  |     | 新的搜索空间文件名             |
  
Chi Song's avatar
Chi Song committed
221
  * 示例
Chi Song's avatar
Chi Song committed
222
    
Chi Song's avatar
Chi Song committed
223
    `使用 'examples/trials/mnist-tfv1/search_space.json' 来更新 Experiment 的搜索空间`
Chi Song's avatar
Chi Song committed
224
    
Chi Song's avatar
Chi Song committed
225
    ```bash
Chi Song's avatar
Chi Song committed
226
    nnictl update searchspace [experiment_id] --filename examples/trials/mnist-tfv1/search_space.json
Chi Song's avatar
Chi Song committed
227
228
229
230
231
    ```

* **nnictl update concurrency**
  
  * 说明
Chi Song's avatar
Chi Song committed
232
    
Chi Song's avatar
Chi Song committed
233
234
235
236
237
238
239
240
241
    可以用此命令来更新 Experiment 的并发设置。
  
  * 用法
    
    ```bash
    nnictl update concurrency [OPTIONS]
    ```
  
  * 选项
Chi Song's avatar
Chi Song committed
242
243
244
  
  | 参数及缩写       | 是否必需  | 默认值 | 说明                    |
  | ----------- | ----- | --- | --------------------- |
Chi Song's avatar
Chi Song committed
245
  | id          | False |     | 需要设置的 Experiment 的 ID |
Chi Song's avatar
Chi Song committed
246
247
  | --value, -v | True  |     | 允许同时运行的 Trial 的数量     |
  
Chi Song's avatar
Chi Song committed
248
  * 示例
Chi Song's avatar
Chi Song committed
249
    
Chi Song's avatar
Chi Song committed
250
    > 更新 Experiment 的并发数量
Chi Song's avatar
Chi Song committed
251
    
Chi Song's avatar
Chi Song committed
252
253
254
255
256
257
258
    ```bash
    nnictl update concurrency [experiment_id] --value [concurrency_number]
    ```

* **nnictl update duration**
  
  * 说明
Chi Song's avatar
Chi Song committed
259
    
Chi Song's avatar
Chi Song committed
260
261
262
263
264
265
266
267
268
269
    可以用此命令来更新 Experiment 的运行时间。
  
  * 用法
    
    ```bash
    nnictl update duration [OPTIONS]
    ```
  
  * 选项
  
Chi Song's avatar
Chi Song committed
270
271
272
273
  | 参数及缩写       | 是否必需  | 默认值 | 说明                                                                       |
  | ----------- | ----- | --- | ------------------------------------------------------------------------ |
  | id          | False |     | 需要设置的 Experiment 的 ID                                                    |
  | --value, -v | True  |     | Experiment 持续时间,如没有单位,则为秒。 后缀可以为 's' 即秒 (默认值), 'm' 即分钟, 'h' 即小时或 'd' 即天。 |
Chi Song's avatar
Chi Song committed
274
  
Chi Song's avatar
Chi Song committed
275
  * 示例
Chi Song's avatar
Chi Song committed
276
277
    
    > 修改 Experiment 的执行时间
Chi Song's avatar
Chi Song committed
278
    
Chi Song's avatar
Chi Song committed
279
280
281
282
283
284
285
    ```bash
    nnictl update duration [experiment_id] --value [duration]
    ```

* **nnictl update trialnum**
  
  * 说明
Chi Song's avatar
Chi Song committed
286
    
Chi Song's avatar
Chi Song committed
287
288
289
    可以用此命令来更新 Experiment 的最大 Trial 数量。
  
  * 用法
Chi Song's avatar
Chi Song committed
290
    
Chi Song's avatar
Chi Song committed
291
292
293
294
295
    ```bash
    nnictl update trialnum [OPTIONS]
    ```
  
  * 选项
Chi Song's avatar
Chi Song committed
296
297
298
299
300
  
  | 参数及缩写       | 是否必需  | 默认值 | 说明                    |
  | ----------- | ----- | --- | --------------------- |
  | id          | False |     | 需要设置的 Experiment 的 id |
  | --value, -v | True  |     | 需要设置的 maxtrialnum 的数量 |
Chi Song's avatar
Chi Song committed
301
  
Chi Song's avatar
Chi Song committed
302
  * 示例
Chi Song's avatar
Chi Song committed
303
304
305
306
307
308
    
    > 更新 Experiment 的 Trial 数量
    
    ```bash
    nnictl update trialnum --id [experiment_id] --value [trial_num]
    ```
Chi Song's avatar
Chi Song committed
309
310

<a name="trial"></a>
Chi Song's avatar
Chi Song committed
311
312

### nnictl trial
Chi Song's avatar
Chi Song committed
313

Chi Song's avatar
Chi Song committed
314
* **nnictl trial ls**
Chi Song's avatar
Chi Song committed
315
  
Chi Song's avatar
Chi Song committed
316
  * 说明
Chi Song's avatar
Chi Song committed
317
    
Chi Song's avatar
Chi Song committed
318
319
320
    使用此命令来查看 Trial 的信息。
  
  * 用法
Chi Song's avatar
Chi Song committed
321
    
Chi Song's avatar
Chi Song committed
322
323
324
325
326
    ```bash
    nnictl trial ls
    ```
  
  * 选项
Chi Song's avatar
Chi Song committed
327
328
329
330
331
  
  | 参数及缩写 | 是否必需  | 默认值 | 说明                    |
  | ----- | ----- | --- | --------------------- |
  | id    | False |     | 需要设置的 Experiment 的 id |

Chi Song's avatar
Chi Song committed
332
* **nnictl trial kill**
Chi Song's avatar
Chi Song committed
333
334
335
  
  * 说明
    
Chi Song's avatar
Chi Song committed
336
    此命令用于终止 Trial。
Chi Song's avatar
Chi Song committed
337
338
339
340
  
  * 用法
    
    ```bash
Chi Song's avatar
Chi Song committed
341
    nnictl trial kill [OPTIONS]
Chi Song's avatar
Chi Song committed
342
343
344
345
    ```
  
  * 选项
  
Chi Song's avatar
Chi Song committed
346
347
348
349
350
  | 参数及缩写          | 是否必需  | 默认值 | 说明                    |
  | -------------- | ----- | --- | --------------------- |
  | id             | False |     | Trial 的 Experiment ID |
  | --trial_id, -T | True  |     | 需要终止的 Trial 的 ID。     |
  
Chi Song's avatar
Chi Song committed
351
  * 示例
Chi Song's avatar
Chi Song committed
352
353
354
355
356
357
358
359
360
    
    > 结束 Trial 任务
    
    ```bash
    nnictl trial [trial_id] --experiment [experiment_id]
    ```

<a name="top"></a>

Chi Song's avatar
Chi Song committed
361
### nnictl top
Chi Song's avatar
Chi Song committed
362
363
364
365
366
367
368
369
370
371
372
373
374

* 说明
  
  查看正在运行的 Experiment。

* 用法
  
  ```bash
  nnictl top
  ```

* 选项
  
Chi Song's avatar
Chi Song committed
375
376
377
378
379
380
  | 参数及缩写      | 是否必需  | 默认值 | 说明                                   |
  | ---------- | ----- | --- | ------------------------------------ |
  | id         | False |     | 需要设置的 Experiment 的 id                |
  | --time, -t | False |     | 刷新 Experiment 状态的时间间隔,单位为秒,默认值为 3 秒。 |

<a name="experiment"></a>
Chi Song's avatar
Chi Song committed
381
382

### 管理 Experiment 信息
Chi Song's avatar
Chi Song committed
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417

* **nnictl experiment show**
  
  * 说明
    
    显示 Experiment 的信息。
  
  * 用法
    
    ```bash
    nnictl experiment show
    ```
  
  * 选项
  
  | 参数及缩写 | 是否必需  | 默认值 | 说明                    |
  | ----- | ----- | --- | --------------------- |
  | id    | False |     | 需要设置的 Experiment 的 id |

* **nnictl experiment status**
  
  * 说明
    
    显示 Experiment 的状态。
  
  * 用法
    
    ```bash
    nnictl experiment status
    ```
  
  * 选项
  
  | 参数及缩写 | 是否必需  | 默认值 | 说明                    |
  | ----- | ----- | --- | --------------------- |
Chi Song's avatar
Chi Song committed
418
  | id    | False |     | 需要设置的 Experiment 的 ID |
Chi Song's avatar
Chi Song committed
419
420
421
422
423
424
425
426
427
428

* **nnictl experiment list**
  
  * 说明
    
    显示正在运行的 Experiment 的信息
  
  * 用法
    
    ```bash
Chi Song's avatar
Chi Song committed
429
    nnictl experiment list [OPTIONS]
Chi Song's avatar
Chi Song committed
430
    ```
Chi Song's avatar
Chi Song committed
431
432
433
434
435
436
  
  * 选项
  
  | 参数及缩写 | 是否必需  | 默认值 | 说明              |
  | ----- | ----- | --- | --------------- |
  | --all | False |     | 列出所有 Experiment |
Chi Song's avatar
Chi Song committed
437

Chi Song's avatar
Chi Song committed
438
439
440
441
442
443
444
445
446
447
448
449
450
451
* **nnictl experiment delete**
  
  * 说明
    
    删除一个或所有 Experiment,包括日志、结果、环境信息和缓存。 用于删除无用的 Experiment 结果,或节省磁盘空间。
  
  * 用法
    
    ```bash
    nnictl experiment delete [OPTIONS]
    ```
  
  * 选项
  
Chi Song's avatar
Chi Song committed
452
453
454
455
  | 参数及缩写 | 是否必需  | 默认值 | 说明              |
  | ----- | ----- | --- | --------------- |
  | id    | False |     | Experiment ID   |
  | --all | False |     | 删除所有 Experiment |
Chi Song's avatar
Chi Song committed
456

Chi Song's avatar
Chi Song committed
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
<a name="export"></a>

* **nnictl experiment export**
  
  * 说明
    
    使用此命令,可将 Trial 的 reward 和超参导出为 csv 文件。
  
  * 用法
    
    ```bash
    nnictl experiment export [OPTIONS]
    ```
  
  * 选项
  
Chi Song's avatar
Chi Song committed
473
474
475
476
477
  | 参数及缩写          | 是否必需  | 默认值 | 说明                        |
  | -------------- | ----- | --- | ------------------------- |
  | id             | False |     | Experiment ID             |
  | --filename, -f | True  |     | 文件的输出路径                   |
  | --type         | True  |     | 输出文件类型,仅支持 "csv" 和 "json" |
Chi Song's avatar
Chi Song committed
478
  
Chi Song's avatar
Chi Song committed
479
  * 示例
Chi Song's avatar
Chi Song committed
480
481
482
483
  
  > 将 Experiment 中所有 Trial 数据导出为 JSON 格式
  
  ```bash
Chi Song's avatar
Chi Song committed
484
  nnictl experiment export [experiment_id] --filename [file_path] --type json
Chi Song's avatar
Chi Song committed
485
  ```
Chi Song's avatar
Chi Song committed
486

Chi Song's avatar
Chi Song committed
487
* **nnictl experiment import**
Chi Song's avatar
Chi Song committed
488
489
490
  
  * 说明
    
Chi Song's avatar
Chi Song committed
491
    可使用此命令将以前的 Trial 超参和结果导入到 Tuner 中。 数据会传入调参算法中(即 Tuner 或 Advisor)。
Chi Song's avatar
Chi Song committed
492
493
494
495
  
  * 用法
    
    ```bash
Chi Song's avatar
Chi Song committed
496
    nnictl experiment import [OPTIONS]
Chi Song's avatar
Chi Song committed
497
    ```
Chi Song's avatar
Chi Song committed
498
499
500
  
  * 选项
  
Chi Song's avatar
Chi Song committed
501
502
503
504
  | 参数及缩写          | 是否必需  | 默认值 | 说明                       |
  | -------------- | ----- | --- | ------------------------ |
  | id             | False |     | 需要将数据导入的 Experiment 的 ID |
  | --filename, -f | True  |     | 需要导入的 JSON 格式的数据文件       |
Chi Song's avatar
Chi Song committed
505
506
507
  
  * 详细说明
    
Chi Song's avatar
Chi Song committed
508
    NNI 支持导入用户的数据,确保数据格式正确。 示例如下:
Chi Song's avatar
Chi Song committed
509
510
511
512
513
514
515
516
517
    
    ```json
    [
      {"parameter": {"x": 0.5, "y": 0.9}, "value": 0.03},
      {"parameter": {"x": 0.4, "y": 0.8}, "value": 0.05},
      {"parameter": {"x": 0.3, "y": 0.7}, "value": 0.04}
    ]
    ```
    
Chi Song's avatar
Chi Song committed
518
    最顶层列表的每个元素都是一个示例。 对于内置的 Tuner 和 Advisor,每个样本至少需要两个主键:`parameter``value``parameter` 必须与 Experiment 的搜索空间相匹配,`parameter` 中的所有的主键(或超参)都必须与搜索空间中的主键相匹配。 否则, Tuner 或 Advisor 可能会有无法预期的行为。 `Value` 应当遵循与 `nni.report_final_result` 的输入值一样的规则,即要么时一个数字,或者是包含 `default` 主键的 dict。 对于自定义的 Tuner 或 Advisor,根据实现的不同,此文件可以是任意的 JSON 内容(例如,`import_data`)。
Chi Song's avatar
Chi Song committed
519
520
521
522
523
    
    也可以用 [nnictl experiment export](#export) 命令导出 Experiment 已经运行过的 Trial 超参和结果。
    
    当前,以下 Tuner 和 Advisor 支持导入数据:
    
Chi Song's avatar
Chi Song committed
524
    ```yaml
Chi Song's avatar
Chi Song committed
525
526
527
528
    内置 Tuner: TPE, Anneal, GridSearch, MetisTuner
    内置 Advisor: BOHB
    ```
    
Chi Song's avatar
Chi Song committed
529
    *如果要将数据导入到 BOHB Advisor,建议像 NNI 一样,增加 "TRIAL_BUDGET" 参数,否则,BOHB 会使用 max_budget 作为 "TRIAL_BUDGET"。 示例如下:*
Chi Song's avatar
Chi Song committed
530
531
532
533
534
535
536
    
    ```json
    [
      {"parameter": {"x": 0.5, "y": 0.9, "TRIAL_BUDGET": 27}, "value": 0.03}
    ]
    ```
  
Chi Song's avatar
Chi Song committed
537
  * 示例
Chi Song's avatar
Chi Song committed
538
539
540
541
    
    > 将数据导入运行中的 Experiment
    
    ```bash
Chi Song's avatar
Chi Song committed
542
    nnictl experiment import [experiment_id] -f experiment_data.json
Chi Song's avatar
Chi Song committed
543
544
    ```

Chi Song's avatar
Chi Song committed
545
<a name="platform"></a>
Chi Song's avatar
Chi Song committed
546
547

### 管理平台信息
Chi Song's avatar
Chi Song committed
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570

* **nnictl platform clean**
  
  * 说明
    
    用于清理目标平台上的磁盘空间。 所提供的 YAML 文件包括了目标平台的信息,与 NNI 配置文件的格式相同。
  
  * 注意
    
    如果目标平台正在被别人使用,可能会造成他人的意外错误。
  
  * 用法
    
    ```bash
    nnictl platform clean [OPTIONS]
    ```
  
  * 选项
  
  | 参数及缩写    | 是否必需 | 默认值 | 说明                            |
  | -------- | ---- | --- | ----------------------------- |
  | --config | True |     | 创建 Experiment 时的 YAML 配置文件路径。 |

Chi Song's avatar
Chi Song committed
571
<a name="config"></a>
Chi Song's avatar
Chi Song committed
572
573

### nnictl config show
Chi Song's avatar
Chi Song committed
574
575
576
577
578
579
580
581
582
583

* 说明
  
  显示当前上下文信息。

* 用法
  
  ```bash
  nnictl config show
  ```
Chi Song's avatar
Chi Song committed
584
585
586

<a name="log"></a>

Chi Song's avatar
Chi Song committed
587
### 管理日志
Chi Song's avatar
Chi Song committed
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604

* **nnictl log stdout**
  
  * 说明
    
    显示 stdout 日志内容。
  
  * 用法
    
    ```bash
    nnictl log stdout [options]
    ```
  
  * 选项
  
  | 参数及缩写      | 是否必需  | 默认值 | 说明                    |
  | ---------- | ----- | --- | --------------------- |
Chi Song's avatar
Chi Song committed
605
  | id         | False |     | 需要设置的 Experiment 的 id |
Chi Song's avatar
Chi Song committed
606
607
608
  | --head, -h | False |     | 显示 stdout 开始的若干行      |
  | --tail, -t | False |     | 显示 stdout 结尾的若干行      |
  | --path, -p | False |     | 显示 stdout 文件的路径       |
Chi Song's avatar
Chi Song committed
609
  
Chi Song's avatar
Chi Song committed
610
  * 示例
Chi Song's avatar
Chi Song committed
611
612
613
614
615
616
    
    > 显示 stdout 结尾的若干行
    
    ```bash
    nnictl log stdout [experiment_id] --tail [lines_number]
    ```
Chi Song's avatar
Chi Song committed
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633

* **nnictl log stderr**
  
  * 说明
    
    显示 stderr 日志内容。
  
  * 用法
    
    ```bash
    nnictl log stderr [options]
    ```
  
  * 选项
  
  | 参数及缩写      | 是否必需  | 默认值 | 说明                    |
  | ---------- | ----- | --- | --------------------- |
Chi Song's avatar
Chi Song committed
634
  | id         | False |     | 需要设置的 Experiment 的 id |
Chi Song's avatar
Chi Song committed
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
  | --head, -h | False |     | 显示 stderr 开始的若干行      |
  | --tail, -t | False |     | 显示 stderr 结尾的若干行      |
  | --path, -p | False |     | 显示 stderr 文件的路径       |

* **nnictl log trial**
  
  * 说明
    
    显示 Trial 日志的路径。
  
  * 用法
    
    ```bash
    nnictl log trial [options]
    ```
  
  * 选项
  
Chi Song's avatar
Chi Song committed
653
654
655
656
  | 参数及缩写          | 是否必需  | 默认值 | 说明                                     |
  | -------------- | ----- | --- | -------------------------------------- |
  | id             | False |     | Trial 的 Experiment ID                  |
  | --trial_id, -T | False |     | 所需要找日志路径的 Trial 的 ID,当 id 不为空时,此值也为必需。 |
Chi Song's avatar
Chi Song committed
657
658

<a name="webui"></a>
Chi Song's avatar
Chi Song committed
659
660

### 管理 Web 界面
Chi Song's avatar
Chi Song committed
661
662
663
664

* **nnictl webui url**

<a name="tensorboard"></a>
Chi Song's avatar
Chi Song committed
665
666

### 管理 TensorBoard
Chi Song's avatar
Chi Song committed
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681

* **nnictl tensorboard start**
  
  * 说明
    
    启动 tensorboard 进程。
  
  * 用法
    
    ```bash
    nnictl tensorboard start
    ```
  
  * 选项
  
Chi Song's avatar
Chi Song committed
682
683
  | 参数及缩写          | 是否必需  | 默认值  | 说明                    |
  | -------------- | ----- | ---- | --------------------- |
Chi Song's avatar
Chi Song committed
684
  | id             | False |      | 需要设置的 Experiment 的 id |
Chi Song's avatar
Chi Song committed
685
  | --trial_id, -T | False |      | Trial 的 ID            |
Chi Song's avatar
Chi Song committed
686
  | --port         | False | 6006 | Tensorboard 进程的端口     |
Chi Song's avatar
Chi Song committed
687
688
689
  
  * 详细说明
    
Chi Song's avatar
Chi Song committed
690
691
692
693
694
    1. NNICTL 当前仅支持本机和远程平台的 Tensorboard,其它平台暂不支持。
    2. 如果要使用 Tensorboard,需要将 Tensorboard 日志输出到环境变量 [NNI_OUTPUT_DIR] 路径下。
    3. 在 local 模式中,nnictl 会直接设置 --logdir=[NNI_OUTPUT_DIR] 并启动 Tensorboard 进程。
    4. 在 remote 模式中,nnictl 会创建一个 SSH 客户端来将日志数据从远程计算机复制到本机临时目录中,然后在本机开始 Tensorboard 进程。 需要注意的是,nnictl 只在使用此命令时复制日志数据,如果要查看最新的 tensorboard 结果,需要再次执行 nnictl tensorboard 命令。
    5. 如果只有一个 Trial 任务,不需要设置 Trial ID。 如果有多个运行的 Trial 任务,需要设置 Trial ID,或使用 [nnictl tensorboard start --trial_id all] 来将 --logdir 映射到所有 Trial 的路径。
Chi Song's avatar
Chi Song committed
695
696
697
698
699

* **nnictl tensorboard stop**
  
  * 说明
    
Chi Song's avatar
Chi Song committed
700
    停止所有 Tensorboard 进程。
Chi Song's avatar
Chi Song committed
701
702
703
704
705
706
707
708
709
  
  * 用法
    
    ```bash
    nnictl tensorboard stop
    ```
  
  * 选项
  
710
711
  | 参数及缩写 | 是否必需  | 默认值 | 说明                    |
  | ----- | ----- | --- | --------------------- |
Chi Song's avatar
Chi Song committed
712
  | id    | False |     | 需要设置的 Experiment 的 ID |
Chi Song's avatar
Chi Song committed
713
714
715

<a name="package"></a>

Chi Song's avatar
Chi Song committed
716
### 管理安装包
Chi Song's avatar
Chi Song committed
717
718
719
720
721

* **nnictl package install**
  
  * 说明
    
Chi Song's avatar
Chi Song committed
722
    安装自定义的 Tuner,Assessor,Advisor(定制或 NNI 提供的算法)。
Chi Song's avatar
Chi Song committed
723
724
725
726
  
  * 用法
    
    ```bash
Chi Song's avatar
Chi Song committed
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
    nnictl package install --name <包名称>
    ```
    
    可通过 `nnictl package list` 命令查看可用的`<包名称>`
    
    或者
    
    ```bash
    nnictl package install <安装源>
    ```
    
    参考[安装自定义算法](InstallCustomizedAlgos.md),来准备安装源。
  
  * 示例
    
    > 安装 SMAC Tuner
    
    ```bash
    nnictl package install --name SMAC
    ```
    
    > 安装自定义 Tuner
    
    ```bash
    nnictl package install nni/examples/tuners/customized_tuner/dist/demo_tuner-0.1-py3-none-any.whl
    ```

* **nnictl package show**
  
  * 说明
    
    显示包的详情。
  
  * 用法
    
    ```bash
    nnictl package show <包名称>
    ```
  
  * 示例
    
    ```bash
    nnictl package show SMAC
    ```

* **nnictl package list**
  
  * 说明
    
    列出安装的、所有包。
  
  * 用法
    
    ```bash
    nnictl package list [OPTIONS]
Chi Song's avatar
Chi Song committed
782
783
784
785
    ```
  
  * 选项
  
Chi Song's avatar
Chi Song committed
786
787
788
  | 参数及缩写 | 是否必需  | 默认值 | 说明    |
  | ----- | ----- | --- | ----- |
  | --all | False |     | 列出所有包 |
Chi Song's avatar
Chi Song committed
789
  
Chi Song's avatar
Chi Song committed
790
  * 示例
Chi Song's avatar
Chi Song committed
791
    
Chi Song's avatar
Chi Song committed
792
793
794
795
796
797
798
    > 列出已安装的包
    
    ```bash
    nnictl package list
    ```
    
    > 列出所有包
Chi Song's avatar
Chi Song committed
799
800
    
    ```bash
Chi Song's avatar
Chi Song committed
801
    nnictl package list --all
Chi Song's avatar
Chi Song committed
802
    ```
Chi Song's avatar
Chi Song committed
803

Chi Song's avatar
Chi Song committed
804
* **nnictl package uninstall**
Chi Song's avatar
Chi Song committed
805
806
807
  
  * 说明
    
Chi Song's avatar
Chi Song committed
808
    卸载包。
Chi Song's avatar
Chi Song committed
809
810
811
812
  
  * 用法
    
    ```bash
Chi Song's avatar
Chi Song committed
813
814
815
816
817
818
819
    nnictl package uninstall <包名称>
    ```
  
  * 示例 卸载 SMAC 包
    
    ```bash
    nnictl package uninstall SMAC
Chi Song's avatar
Chi Song committed
820
821
    ```

Chi Song's avatar
Chi Song committed
822
823
<a name="ss_gen"></a>

Chi Song's avatar
Chi Song committed
824
### 生成搜索空间
Chi Song's avatar
Chi Song committed
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853

* **nnictl ss_gen**
  
  * 说明
    
    从使用 NNI NAS API 的用户代码生成搜索空间。
  
  * 用法
    
    ```bash
    nnictl ss_gen [OPTIONS]
    ```
  
  * 选项
  
  | 参数及缩写           | 是否必需  | 默认值                                | 说明          |
  | --------------- | ----- | ---------------------------------- | ----------- |
  | --trial_command | True  |                                    | Trial 代码的命令 |
  | --trial_dir     | False | ./                                 | Trial 代码目录  |
  | --file          | False | nni_auto_gen_search_space.json | 用来存储生成的搜索空间 |
  
  * 示例
    
    > 生成搜索空间
    
    ```bash
    nnictl ss_gen --trial_command="python3 mnist.py" --trial_dir=./ --file=ss.json
    ```

Chi Song's avatar
Chi Song committed
854
855
<a name="version"></a>

Chi Song's avatar
Chi Song committed
856
### NNI 版本校验
Chi Song's avatar
Chi Song committed
857
858
859
860
861
862
863
864
865
866
867

* **nnictl --version**
  
  * 说明
    
    显示当前安装的 NNI 的版本。
  
  * 用法
    
    ```bash
    nnictl --version
Chi Song's avatar
Chi Song committed
868
    ```