NNICTLDOC.md 15.4 KB
Newer Older
QuanluZhang's avatar
QuanluZhang committed
1
# nnictl
Chi Song's avatar
Chi Song committed
2

QuanluZhang's avatar
QuanluZhang committed
3
## Introduction
Chi Song's avatar
Chi Song committed
4

QuanluZhang's avatar
QuanluZhang committed
5
6
7
__nnictl__ is a command line tool, which can be used to control experiments, such as start/stop/resume an experiment, start/stop NNIBoard, etc.

## Commands
Chi Song's avatar
Chi Song committed
8

QuanluZhang's avatar
QuanluZhang committed
9
nnictl support commands:
Chi Song's avatar
Chi Song committed
10

11
12
13
14
15
16
17
18
19
20
21
22
23
* [nnictl create](#create)
* [nnictl resume](#resume)
* [nnictl stop](#stop)
* [nnictl update](#update)
* [nnictl trial](#trial)
* [nnictl top](#top)
* [nnictl experiment](#experiment)
* [nnictl config](#config)
* [nnictl log](#log)
* [nnictl webui](#webui)
* [nnictl tensorboard](#tensorboard)
* [nnictl package](#package)
* [nnictl --version](#version)
Chi Song's avatar
Chi Song committed
24

Yan Ni's avatar
Yan Ni committed
25
### Manage an experiment
26

Yan Ni's avatar
Yan Ni committed
27
<a name="create"></a>
28
![](https://placehold.it/15/1589F0/000000?text=+) `nnictl create`
29

30
* Description
31

32
  You can use this command to create a new experiment, using the configuration specified in config file. 
33

34
  After this command is successfully done, the context will be set as this experiment, which means the following command you issued is associated with this experiment, unless you explicitly changes the context(not supported yet).
35

36
* Usage
37

38
39
40
  ```bash
  nnictl create [OPTIONS]
  ```
41

42
* Options
43

Chi Song's avatar
Chi Song committed
44
45
46
47
  |Name, shorthand|Required|Default|Description|
  |------|------|------|------|
  |--config, -c|  True| |YAML configure file of the experiment|
  |--port, -p|False| |the port of restful server|
48
49
  |--debug, -d|False||set debug mode|

50
* Examples
51

52
  > create a new experiment with the default port: 8080
53

54
55
56
  ```bash
  nnictl create --config nni/examples/trials/mnist/config.yml
  ```
57

58
  > create a new experiment with specified port 8088
59

60
61
62
  ```bash
  nnictl create --config nni/examples/trials/mnist/config.yml --port 8088
  ```
63

64
  > create a new experiment with specified port 8088 and debug mode
65

66
67
  ```bash
  nnictl create --config nni/examples/trials/mnist/config.yml --port 8088 --debug
68
  ```
69

70
71
72
73
74
75
Note:

```text
Debug mode will disable version check function in Trialkeeper.
```

Yan Ni's avatar
Yan Ni committed
76
<a name="resume"></a>
77
78

![](https://placehold.it/15/1589F0/000000?text=+) `nnictl resume`
QuanluZhang's avatar
QuanluZhang committed
79

80
* Description
Chi Song's avatar
Chi Song committed
81

82
  You can use this command to resume a stopped experiment.
Chi Song's avatar
Chi Song committed
83

84
* Usage
Chi Song's avatar
Chi Song committed
85

86
87
88
  ```bash
  nnictl resume [OPTIONS]
  ```
Chi Song's avatar
Chi Song committed
89

90
* Options
91

Chi Song's avatar
Chi Song committed
92
93
  |Name, shorthand|Required|Default|Description|
  |------|------|------ |------|
94
  |id|  True| |The id of the experiment you want to resume|  
Chi Song's avatar
Chi Song committed
95
  |--port, -p|  False| |Rest port of the experiment you want to resume|
96
  |--debug, -d|False||set debug mode|
Chi Song's avatar
Chi Song committed
97

98
* Example
99

100
  > resume an experiment with specified port 8088
101

102
103
104
  ```bash
  nnictl resume [experiment_id] --port 8088
  ```
105

Yan Ni's avatar
Yan Ni committed
106
<a name="stop"></a>
107
![](https://placehold.it/15/1589F0/000000?text=+) `nnictl stop`
108

109
* Description
Chi Song's avatar
Chi Song committed
110

111
  You can use this command to stop a running experiment or multiple experiments.
Chi Song's avatar
Chi Song committed
112

113
* Usage
Chi Song's avatar
Chi Song committed
114

115
116
117
  ```bash
  nnictl stop [id]
  ```
118

119
* Details & Examples
120

121
  1. If there is no id specified, and there is an experiment running, stop the running experiment, or print error message.
122
123
124
125
126

      ```bash
      nnictl stop
      ```

127
  1. If there is an id specified, and the id matches the running experiment, nnictl will stop the corresponding experiment, or will print error message.
128
129
130
131
132

      ```bash
      nnictl stop [experiment_id]
      ```

133
  1. Users could use 'nnictl stop all' to stop all experiments.
134
135
136
137

      ```bash
      nnictl stop all
      ```
138
139
140
141

  1. If the id ends with *, nnictl will stop all experiments whose ids matchs the regular.
  1. If the id does not exist but match the prefix of an experiment id, nnictl will stop the matched experiment.
  1. If the id does not exist but match multiple prefix of the experiment ids, nnictl will give id information.
142

Yan Ni's avatar
Yan Ni committed
143
<a name="update"></a>
144
145

![](https://placehold.it/15/1589F0/000000?text=+) `nnictl update`
146

147
148
* __nnictl update searchspace__
  * Description
149

150
    You can use this command to update an experiment's search space.
151

152
  * Usage
153

154
155
156
    ```bash
    nnictl update searchspace [OPTIONS]
    ```
157

158
  * Options
159

160
161
162
163
  |Name, shorthand|Required|Default|Description|
  |------|------|------ |------|
  |id|  False| |ID of the experiment you want to set|
  |--filename, -f|  True| |the file storing your new search space|
164

165
  * Example
166

167
    `update experiment's new search space with file dir 'examples/trials/mnist/search_space.json'`
168

169
    ```bash
170
    nnictl update searchspace [experiment_id] --filename examples/trials/mnist/search_space.json
171
    ```
172

173
* __nnictl update concurrency__  
174

175
  * Description
176

177
     You can use this command to update an experiment's concurrency.
178

179
  * Usage
180

181
182
183
    ```bash
    nnictl update concurrency [OPTIONS]
    ```
184

185
  * Options
186

187
188
189
190
  |Name, shorthand|Required|Default|Description|
  |------|------|------ |------|
  |id|  False| |ID of the experiment you want to set|
  |--value, -v|  True| |the number of allowed concurrent trials|
191

192
  * Example
193

194
    > update experiment's concurrency
195

196
197
198
    ```bash
    nnictl update concurrency [experiment_id] --value [concurrency_number]
    ```
199

200
* __nnictl update duration__  
201

202
  * Description
203

204
    You can use this command to update an experiment's duration.  
205

206
  * Usage
207

208
209
210
    ```bash
    nnictl update duration [OPTIONS]
    ```
211

212
  * Options
213

214
215
216
217
  |Name, shorthand|Required|Default|Description|
  |------|------|------ |------|
  |id|  False| |ID of the experiment you want to set|
  |--value, -v|  True| |the experiment duration will be NUMBER seconds. SUFFIX may be 's' for seconds (the default), 'm' for minutes, 'h' for hours or 'd' for days.|
218

219
  * Example
220

221
    > update experiment's duration
222

223
224
225
    ```bash
    nnictl update duration [experiment_id] --value [duration]
    ```
226

227
228
* __nnictl update trialnum__  
  * Description
229

230
    You can use this command to update an experiment's maxtrialnum.
231

232
  * Usage
233

234
235
236
    ```bash
    nnictl update trialnum [OPTIONS]
    ```
237

238
  * Options
239

240
241
242
243
  |Name, shorthand|Required|Default|Description|
  |------|------|------ |------|
  |id|  False| |ID of the experiment you want to set|
  |--value, -v|  True| |the new number of maxtrialnum you want to set|
244

245
  * Example
246

247
    > update experiment's trial num
248

249
250
251
    ```bash
    nnictl update trialnum --id [experiment_id] --value [trial_num]
    ```
252

253
<a name="trial"></a>
254
![](https://placehold.it/15/1589F0/000000?text=+) `nnictl trial`
Chi Song's avatar
Chi Song committed
255

256
* __nnictl trial ls__
Chi Song's avatar
Chi Song committed
257

258
  * Description
Chi Song's avatar
Chi Song committed
259

260
    You can use this command to show trial's information.
Chi Song's avatar
Chi Song committed
261

262
  * Usage
263

264
265
266
    ```bash
    nnictl trial ls
    ```
QuanluZhang's avatar
QuanluZhang committed
267

268
  * Options
Chi Song's avatar
Chi Song committed
269

270
271
272
  |Name, shorthand|Required|Default|Description|
  |------|------|------ |------|
  |id|  False| |ID of the experiment you want to set|
SparkSnail's avatar
SparkSnail committed
273

274
* __nnictl trial kill__
275

276
  * Description
277

278
    You can use this command to kill a trial job.
279

280
  * Usage
281

282
283
284
    ```bash
    nnictl trial kill [OPTIONS]
    ```
285

286
  * Options
287

288
289
  |Name, shorthand|Required|Default|Description|
  |------|------|------ |------|
290
291
  |id|  False| |Experiment ID of the trial|
  |--trial_id, -T|  True| |ID of the trial you want to kill.|
292

293
  * Example
294

295
    > kill trail job
296

297
    ```bash
Chi Song's avatar
Chi Song committed
298
    nnictl trial [trial_id] --experiment [experiment_id]
299
300
    ```

Yan Ni's avatar
Yan Ni committed
301
<a name="top"></a>
302
303

![](https://placehold.it/15/1589F0/000000?text=+) `nnictl top`
SparkSnail's avatar
SparkSnail committed
304

305
* Description
306

307
  Monitor all of running experiments.
308

309
* Usage
310

311
312
313
  ```bash
  nnictl top
  ```
314

315
* Options  
316

Chi Song's avatar
Chi Song committed
317
318
319
320
  |Name, shorthand|Required|Default|Description|
  |------|------|------ |------|
  |id|  False| |ID of the experiment you want to set|
  |--time, -t|  False| |The interval to update the experiment status, the unit of time is second, and the default value is 3 second.|
321

Yan Ni's avatar
Yan Ni committed
322
<a name="experiment"></a>
323
![](https://placehold.it/15/1589F0/000000?text=+) `Manage experiment information`
QuanluZhang's avatar
QuanluZhang committed
324
325

* __nnictl experiment show__
Chi Song's avatar
Chi Song committed
326

QuanluZhang's avatar
QuanluZhang committed
327
  * Description
SparkSnail's avatar
SparkSnail committed
328

Chi Song's avatar
Chi Song committed
329
330
331
332
333
334
335
336
    Show the information of experiment.

  * Usage

    ```bash
    nnictl experiment show
    ```

337
  * Options
Chi Song's avatar
Chi Song committed
338

Chi Song's avatar
Chi Song committed
339
340
341
  |Name, shorthand|Required|Default|Description|
  |------|------|------ |------|
  |id|  False| |ID of the experiment you want to set|
SparkSnail's avatar
SparkSnail committed
342
343

* __nnictl experiment status__
Chi Song's avatar
Chi Song committed
344

SparkSnail's avatar
SparkSnail committed
345
346
  * Description

Chi Song's avatar
Chi Song committed
347
348
349
350
351
352
353
354
    Show the status of experiment.

  * Usage

    ```bash
    nnictl experiment status
    ```

355
  * Options
Chi Song's avatar
Chi Song committed
356

Chi Song's avatar
Chi Song committed
357
358
359
  |Name, shorthand|Required|Default|Description|
  |------|------|------ |------|
  |id|  False| |ID of the experiment you want to set|
SparkSnail's avatar
SparkSnail committed
360
361

* __nnictl experiment list__
362

SparkSnail's avatar
SparkSnail committed
363
  * Description
QuanluZhang's avatar
QuanluZhang committed
364

Chi Song's avatar
Chi Song committed
365
366
367
    Show the information of all the (running) experiments.

  * Usage
368

Chi Song's avatar
Chi Song committed
369
370
371
372
    ```bash
    nnictl experiment list
    ```

373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
<a name="export"></a>

* __nnictl experiment export__
  * Description

    You can use this command to export reward & hyper-parameter of trial jobs to a csv file.

  * Usage

    ```bash
    nnictl experiment export [OPTIONS]
    ```

  * Options

  |Name, shorthand|Required|Default|Description|
  |------|------|------ |------|
  |id|  False| |ID of the experiment    |
391
  |--filename, -f|  True| |File path of the output file     |
392
393
394
395
396
397
398
  |--type|  True| |Type of output file, only support "csv" and "json"|

  * Examples

  > export all trial data in an experiment as json format

  ```bash
399
  nnictl experiment export [experiment_id] --filename [file_path] --type json
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
  ```

* __nnictl experiment import__
  * Description

    You can use this command to import several prior or supplementary trial hyperparameters & results for NNI hyperparameter tuning. The data are fed to the tuning algorithm (e.g., tuner or advisor).

  * Usage

    ```bash
    nnictl experiment import [OPTIONS]
    ```

  * Options

  |Name, shorthand|Required|Default|Description|
  |------|------|------|------|
  |id|  False| |The id of the experiment you want to import data into|
418
  |--filename, -f|  True| |a file with data you want to import in json format|
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435

  * Details

    NNI supports users to import their own data, please express the data in the correct format. An example is shown below:

    ```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}
    ]
    ```

    Every element in the top level list is a sample. For our built-in tuners/advisors, each sample should have at least two keys: `parameter` and `value`. The `parameter` must match this experiment's search space, that is, all the keys (or hyperparameters) in `parameter` must match the keys in the search space. Otherwise, tuner/advisor may have unpredictable behavior. `Value` should follow the same rule of the input in `nni.report_final_result`, that is, either a number or a dict with a key named `default`. For your customized tuner/advisor, the file could have any json content depending on how you implement the corresponding methods (e.g., `import_data`).

    You also can use [nnictl experiment export](#export) to export a valid json file including previous experiment trial hyperparameters and results.

Chi Song's avatar
Chi Song committed
436
    Currently, following tuner and advisor support import data:
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458

    ```yml
    builtinTunerName: TPE, Anneal, GridSearch, MetisTuner
    builtinAdvisorName: BOHB
    ```

    *If you want to import data to BOHB advisor, user are suggested to add "TRIAL_BUDGET" in parameter as NNI do, otherwise, BOHB will use max_budget as "TRIAL_BUDGET". Here is an example:*

    ```json
    [
      {"parameter": {"x": 0.5, "y": 0.9, "TRIAL_BUDGET": 27}, "value": 0.03}
    ]
    ```

  * Examples

    > import data to a running experiment

    ```bash
    nnictl experiment [experiment_id] -f experiment_data.json
    ```

Yan Ni's avatar
Yan Ni committed
459
<a name="config"></a>
460
![](https://placehold.it/15/1589F0/000000?text=+) `nnictl config show`
461

462
* Description
463

464
  Display the current context information.
465

466
* Usage
467

468
469
470
  ```bash
  nnictl config show
  ```
471

Yan Ni's avatar
Yan Ni committed
472
<a name="log"></a>
473
474

![](https://placehold.it/15/1589F0/000000?text=+) `Manage log`
Chi Song's avatar
Chi Song committed
475

QuanluZhang's avatar
QuanluZhang committed
476
* __nnictl log stdout__
Chi Song's avatar
Chi Song committed
477
478
479
480
481
482
483
484
485
486
487

  * Description

    Show the stdout log content.

  * Usage

    ```bash
    nnictl log stdout [options]
    ```

488
  * Options
Chi Song's avatar
Chi Song committed
489

Chi Song's avatar
Chi Song committed
490
491
492
493
494
495
  |Name, shorthand|Required|Default|Description|
  |------|------|------ |------|
  |id|  False| |ID of the experiment you want to set|
  |--head, -h| False| |show head lines of stdout|
  |--tail, -t|  False| |show tail lines of stdout|
  |--path, -p|  False| |show the path of stdout file|
Chi Song's avatar
Chi Song committed
496

497
498
499
500
501
502
503
504
  * Example

    > Show the tail of stdout log content

    ```bash
    nnictl log stdout [experiment_id] --tail [lines_number]
    ```

QuanluZhang's avatar
QuanluZhang committed
505
506
* __nnictl log stderr__
  * Description
Chi Song's avatar
Chi Song committed
507
508

    Show the stderr log content.
509

QuanluZhang's avatar
QuanluZhang committed
510
  * Usage
Chi Song's avatar
Chi Song committed
511
512
513
514
515

    ```bash
    nnictl log stderr [options]
    ```

516
  * Options
Chi Song's avatar
Chi Song committed
517

Chi Song's avatar
Chi Song committed
518
519
520
521
522
523
  |Name, shorthand|Required|Default|Description|
  |------|------|------ |------|
  |id|  False| |ID of the experiment you want to set|
  |--head, -h| False| |show head lines of stderr|
  |--tail, -t|  False| |show tail lines of stderr|
  |--path, -p|  False| |show the path of stderr file|
524
525

* __nnictl log trial__
526

527
528
  * Description
  
Chi Song's avatar
Chi Song committed
529
    Show trial log path.
530
531
  
  * Usage
SparkSnail's avatar
SparkSnail committed
532

533
534
535
536
537
538
    ```bash  
    nnictl log trial [options]
    ```

  * Options

Chi Song's avatar
Chi Song committed
539
540
  |Name, shorthand|Required|Default|Description|
  |------|------|------ |------|
541
542
  |id|  False| |Experiment ID of the trial|
  |--trial_id, -T|  False| |ID of the trial to be found the log path, required when id is not empty.|
543

Yan Ni's avatar
Yan Ni committed
544
<a name="webui"></a>
545
![](https://placehold.it/15/1589F0/000000?text=+) `Manage webui`
Chi Song's avatar
Chi Song committed
546

SparkSnail's avatar
SparkSnail committed
547
* __nnictl webui url__
SparkSnail's avatar
SparkSnail committed
548

Yan Ni's avatar
Yan Ni committed
549
<a name="tensorboard"></a>
550
![](https://placehold.it/15/1589F0/000000?text=+) `Manage tensorboard`
Chi Song's avatar
Chi Song committed
551

SparkSnail's avatar
SparkSnail committed
552
* __nnictl tensorboard start__
Chi Song's avatar
Chi Song committed
553
554
555
556
557
558
559
560
561
562
563

  * Description

    Start the tensorboard process.
  
  * Usage

    ```bash
    nnictl tensorboard start
    ```

564
  * Options
Chi Song's avatar
Chi Song committed
565

Chi Song's avatar
Chi Song committed
566
567
568
  |Name, shorthand|Required|Default|Description|
  |------|------|------ |------|
  |id|  False| |ID of the experiment you want to set|
569
  |--trial_id, -T|  False| |ID of the trial|
Chi Song's avatar
Chi Song committed
570
  |--port|  False| 6006|The port of the tensorboard process|
Chi Song's avatar
Chi Song committed
571
572
573
574
575
576
577

  * Detail

    1. NNICTL support tensorboard function in local and remote platform for the moment, other platforms will be supported later.   
    2. If you want to use tensorboard, you need to write your tensorboard log data to environment variable [NNI_OUTPUT_DIR] path.  
    3. In local mode, nnictl will set --logdir=[NNI_OUTPUT_DIR] directly and start a tensorboard process.
    4. In remote mode, nnictl will create a ssh client to copy log data from remote machine to local temp directory firstly, and then start a tensorboard process in your local machine. You need to notice that nnictl only copy the log data one time when you use the command, if you want to see the later result of tensorboard, you should execute nnictl tensorboard command again.
578
    5. If there is only one trial job, you don't need to set trial id. If there are multiple trial jobs running, you should set the trial id, or you could use [nnictl tensorboard start --trial_id all] to map --logdir to all trial log paths.
SparkSnail's avatar
SparkSnail committed
579
580

* __nnictl tensorboard stop__
581
582
  * Description

583
    Stop all of the tensorboard process.
584
585
586
587
588
589
590
591
592

  * Usage

    ```bash
    nnictl tensorboard stop
    ```

  * Options

Chi Song's avatar
Chi Song committed
593
594
595
  |Name, shorthand|Required|Default|Description|
  |------|------|------ |------|
  |id|  False| |ID of the experiment you want to set|
Yan Ni's avatar
Yan Ni committed
596
597

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

![](https://placehold.it/15/1589F0/000000?text=+) `Manage package`
600

Yan Ni's avatar
Yan Ni committed
601
* __nnictl package install__
602
603
604
605
606
607
608
609
610
611
612
613
  * Description

    Install the packages needed in nni experiments.

  * Usage

    ```bash
    nnictl package install [OPTIONS]
    ```

  * Options

Chi Song's avatar
Chi Song committed
614
615
616
  |Name, shorthand|Required|Default|Description|
  |------|------|------ |------|
  |--name|  True| |The name of package to be installed|
Yan Ni's avatar
Yan Ni committed
617

618
619
620
621
622
623
624
625
  * Example

    > Install the packages needed in tuner SMAC

    ```bash
    nnictl package install --name=SMAC
    ```

Yan Ni's avatar
Yan Ni committed
626
* __nnictl package show__
627
628
629
630
631
632
633
634
635
636
637
638

  * Description

    List the packages supported.

  * Usage

    ```bash
    nnictl package show
    ```

<a name="version"></a>
639
640

![](https://placehold.it/15/1589F0/000000?text=+) `Check NNI version`
641
642
643
644
645
646
647
648
649
650
651

* __nnictl --version__

  * Description

    Describe the current version of NNI installed.

  * Usage

    ```bash
    nnictl --version
652
    ```