Nnictl.md 17.1 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
* [nnictl create](#create)
* [nnictl resume](#resume)
* [nnictl stop](#stop)
* [nnictl update](#update)
* [nnictl trial](#trial)
* [nnictl top](#top)
* [nnictl experiment](#experiment)
SparkSnail's avatar
SparkSnail committed
18
* [nnictl platform](#platform)
19
20
21
22
23
24
* [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
25

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

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

31
* Description
32

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

35
  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).
36

37
* Usage
38

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

43
* Options
44

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

51
* Examples
52

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

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

59
  > create a new experiment with specified port 8088
60

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

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

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

71
72
73
74
75
76
Note:

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

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

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

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

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

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

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

91
* Options
92

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

99
* Example
100

101
  > resume an experiment with specified port 8088
102

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

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

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

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

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

116
  ```bash
117
  nnictl stop [Options]
118
  ```
119

120
121
122
123
124
125
* Options

  |Name, shorthand|Required|Default|Description|
  |------|------|------ |------|
  |id|  False| |The id of the experiment you want to stop|
  |--port, -p|  False| |Rest port of the experiment you want to stop|
126
  |--all, -a|  False| |Stop all of experiments|
127

128
* Details & Examples
129

130
  1. If there is no id specified, and there is an experiment running, stop the running experiment, or print error message.
131
132
133
134
135

      ```bash
      nnictl stop
      ```

136
  2. If there is an id specified, and the id matches the running experiment, nnictl will stop the corresponding experiment, or will print error message.
137
138
139
140
141

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

142
143
144
145
146
147
  3. If there is a port specified, and an experiment is running on that port, the experiment will be stopped.

      ```bash
      nnictl stop --port 8080
      ```

148
  4. Users could use 'nnictl stop --all' to stop all experiments.
149
150

      ```bash
151
      nnictl stop --all
152
      ```
153

154
155
156
  5. If the id ends with *, nnictl will stop all experiments whose ids matchs the regular.
  6. If the id does not exist but match the prefix of an experiment id, nnictl will stop the matched experiment.
  7. If the id does not exist but match multiple prefix of the experiment ids, nnictl will give id information.
157

Yan Ni's avatar
Yan Ni committed
158
<a name="update"></a>
159
160

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

162
163
* __nnictl update searchspace__
  * Description
164

165
    You can use this command to update an experiment's search space.
166

167
  * Usage
168

169
170
171
    ```bash
    nnictl update searchspace [OPTIONS]
    ```
172

173
  * Options
174

175
176
177
178
  |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|
179

180
  * Example
181

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

184
    ```bash
185
    nnictl update searchspace [experiment_id] --filename examples/trials/mnist/search_space.json
186
    ```
187

188
* __nnictl update concurrency__
189

190
  * Description
191

192
     You can use this command to update an experiment's concurrency.
193

194
  * Usage
195

196
197
198
    ```bash
    nnictl update concurrency [OPTIONS]
    ```
199

200
  * Options
201

202
203
204
205
  |Name, shorthand|Required|Default|Description|
  |------|------|------ |------|
  |id|  False| |ID of the experiment you want to set|
  |--value, -v|  True| |the number of allowed concurrent trials|
206

207
  * Example
208

209
    > update experiment's concurrency
210

211
212
213
    ```bash
    nnictl update concurrency [experiment_id] --value [concurrency_number]
    ```
214

215
* __nnictl update duration__
216

217
  * Description
218

219
    You can use this command to update an experiment's duration.
220

221
  * Usage
222

223
224
225
    ```bash
    nnictl update duration [OPTIONS]
    ```
226

227
  * Options
228

229
230
231
232
  |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.|
233

234
  * Example
235

236
    > update experiment's duration
237

238
239
240
    ```bash
    nnictl update duration [experiment_id] --value [duration]
    ```
241

242
* __nnictl update trialnum__
243
  * Description
244

245
    You can use this command to update an experiment's maxtrialnum.
246

247
  * Usage
248

249
250
251
    ```bash
    nnictl update trialnum [OPTIONS]
    ```
252

253
  * Options
254

255
256
257
258
  |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|
259

260
  * Example
261

262
    > update experiment's trial num
263

264
265
266
    ```bash
    nnictl update trialnum --id [experiment_id] --value [trial_num]
    ```
267

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

271
* __nnictl trial ls__
Chi Song's avatar
Chi Song committed
272

273
  * Description
Chi Song's avatar
Chi Song committed
274

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

277
  * Usage
278

279
280
281
    ```bash
    nnictl trial ls
    ```
QuanluZhang's avatar
QuanluZhang committed
282

283
  * Options
Chi Song's avatar
Chi Song committed
284

285
286
287
  |Name, shorthand|Required|Default|Description|
  |------|------|------ |------|
  |id|  False| |ID of the experiment you want to set|
SparkSnail's avatar
SparkSnail committed
288

289
* __nnictl trial kill__
290

291
  * Description
292

293
    You can use this command to kill a trial job.
294

295
  * Usage
296

297
298
299
    ```bash
    nnictl trial kill [OPTIONS]
    ```
300

301
  * Options
302

303
304
  |Name, shorthand|Required|Default|Description|
  |------|------|------ |------|
305
306
  |id|  False| |Experiment ID of the trial|
  |--trial_id, -T|  True| |ID of the trial you want to kill.|
307

308
  * Example
309

310
    > kill trail job
311

312
    ```bash
Chi Song's avatar
Chi Song committed
313
    nnictl trial [trial_id] --experiment [experiment_id]
314
315
    ```

Yan Ni's avatar
Yan Ni committed
316
<a name="top"></a>
317
318

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

320
* Description
321

322
  Monitor all of running experiments.
323

324
* Usage
325

326
327
328
  ```bash
  nnictl top
  ```
329

330
* Options
331

Chi Song's avatar
Chi Song committed
332
333
334
335
  |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.|
336

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

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

QuanluZhang's avatar
QuanluZhang committed
342
  * Description
SparkSnail's avatar
SparkSnail committed
343

Chi Song's avatar
Chi Song committed
344
345
346
347
348
349
350
351
    Show the information of experiment.

  * Usage

    ```bash
    nnictl experiment show
    ```

352
  * Options
Chi Song's avatar
Chi Song committed
353

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

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

SparkSnail's avatar
SparkSnail committed
360
361
  * Description

Chi Song's avatar
Chi Song committed
362
363
364
365
366
367
368
369
    Show the status of experiment.

  * Usage

    ```bash
    nnictl experiment status
    ```

370
  * Options
Chi Song's avatar
Chi Song committed
371

Chi Song's avatar
Chi Song committed
372
373
374
  |Name, shorthand|Required|Default|Description|
  |------|------|------ |------|
  |id|  False| |ID of the experiment you want to set|
SparkSnail's avatar
SparkSnail committed
375
376

* __nnictl experiment list__
377

SparkSnail's avatar
SparkSnail committed
378
  * Description
QuanluZhang's avatar
QuanluZhang committed
379

Chi Song's avatar
Chi Song committed
380
381
382
    Show the information of all the (running) experiments.

  * Usage
383

Chi Song's avatar
Chi Song committed
384
    ```bash
SparkSnail's avatar
SparkSnail committed
385
    nnictl experiment list [OPTIONS]
Chi Song's avatar
Chi Song committed
386
    ```
SparkSnail's avatar
SparkSnail committed
387
388
389
390
391
392
  
  * Options

  |Name, shorthand|Required|Default|Description|
  |------|------|------ |------|
  |--all|  False| |list all of experiments|
Chi Song's avatar
Chi Song committed
393

SparkSnail's avatar
SparkSnail committed
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
* __nnictl experiment delete__

  * Description

    Delete one or all experiments, it includes log, result, environment information and cache. It uses to delete useless experiment result, or save disk space.

  * Usage

    ```bash
    nnictl experiment delete [OPTIONS]
    ```
  
  * Options

  |Name, shorthand|Required|Default|Description|
  |------|------|------ |------|
  |id|  False| |ID of the experiment|
SparkSnail's avatar
SparkSnail committed
411
  |--all|  False| |delete all of experiments|
SparkSnail's avatar
SparkSnail committed
412
413
414



415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
<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    |
433
  |--filename, -f|  True| |File path of the output file     |
434
435
436
437
438
439
440
  |--type|  True| |Type of output file, only support "csv" and "json"|

  * Examples

  > export all trial data in an experiment as json format

  ```bash
441
  nnictl experiment export [experiment_id] --filename [file_path] --type json
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
  ```

* __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|
460
  |--filename, -f|  True| |a file with data you want to import in json format|
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477

  * 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
478
    Currently, following tuner and advisor support import data:
479

480
    ```yaml
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
    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
498
    nnictl experiment import [experiment_id] -f experiment_data.json
499
500
    ```

SparkSnail's avatar
SparkSnail committed
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
<a name="platform"></a>
![](https://placehold.it/15/1589F0/000000?text=+) `Manage platform information`

* __nnictl platform clean__

  * Description

    It uses to clean up disk on a target platform. The provided YAML file includes the information of target platform, and it follows the same schema as the NNI configuration file.

  * Note
   
    if the target platform is being used by other users, it may cause unexpected errors to others.

  * Usage

    ```bash
    nnictl platform clean [OPTIONS]
    ```

  * Options

  |Name, shorthand|Required|Default|Description|
  |------|------|------ |------|
  |--config|  True| |the path of yaml config file used when create an experiment|


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

530
* Description
531

532
  Display the current context information.
533

534
* Usage
535

536
537
538
  ```bash
  nnictl config show
  ```
539

Yan Ni's avatar
Yan Ni committed
540
<a name="log"></a>
541
542

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

QuanluZhang's avatar
QuanluZhang committed
544
* __nnictl log stdout__
Chi Song's avatar
Chi Song committed
545
546
547
548
549
550
551
552
553
554
555

  * Description

    Show the stdout log content.

  * Usage

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

556
  * Options
Chi Song's avatar
Chi Song committed
557

Chi Song's avatar
Chi Song committed
558
559
560
561
562
563
  |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
564

565
566
567
568
569
570
571
572
  * Example

    > Show the tail of stdout log content

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

QuanluZhang's avatar
QuanluZhang committed
573
574
* __nnictl log stderr__
  * Description
Chi Song's avatar
Chi Song committed
575
576

    Show the stderr log content.
577

QuanluZhang's avatar
QuanluZhang committed
578
  * Usage
Chi Song's avatar
Chi Song committed
579
580
581
582
583

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

584
  * Options
Chi Song's avatar
Chi Song committed
585

Chi Song's avatar
Chi Song committed
586
587
588
589
590
591
  |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|
592
593

* __nnictl log trial__
594

595
  * Description
596

Chi Song's avatar
Chi Song committed
597
    Show trial log path.
598

599
  * Usage
SparkSnail's avatar
SparkSnail committed
600

601
    ```bash
602
603
604
605
606
    nnictl log trial [options]
    ```

  * Options

Chi Song's avatar
Chi Song committed
607
608
  |Name, shorthand|Required|Default|Description|
  |------|------|------ |------|
609
610
  |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.|
611

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

SparkSnail's avatar
SparkSnail committed
615
* __nnictl webui url__
SparkSnail's avatar
SparkSnail committed
616

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

SparkSnail's avatar
SparkSnail committed
620
* __nnictl tensorboard start__
Chi Song's avatar
Chi Song committed
621
622
623
624

  * Description

    Start the tensorboard process.
625

Chi Song's avatar
Chi Song committed
626
627
628
629
630
631
  * Usage

    ```bash
    nnictl tensorboard start
    ```

632
  * Options
Chi Song's avatar
Chi Song committed
633

Chi Song's avatar
Chi Song committed
634
635
636
  |Name, shorthand|Required|Default|Description|
  |------|------|------ |------|
  |id|  False| |ID of the experiment you want to set|
637
  |--trial_id, -T|  False| |ID of the trial|
Chi Song's avatar
Chi Song committed
638
  |--port|  False| 6006|The port of the tensorboard process|
Chi Song's avatar
Chi Song committed
639
640
641

  * Detail

642
643
    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.
Chi Song's avatar
Chi Song committed
644
645
    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.
646
    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
647
648

* __nnictl tensorboard stop__
649
650
  * Description

651
    Stop all of the tensorboard process.
652
653
654
655
656
657
658
659
660

  * Usage

    ```bash
    nnictl tensorboard stop
    ```

  * Options

Chi Song's avatar
Chi Song committed
661
662
663
  |Name, shorthand|Required|Default|Description|
  |------|------|------ |------|
  |id|  False| |ID of the experiment you want to set|
Yan Ni's avatar
Yan Ni committed
664
665

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

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

Yan Ni's avatar
Yan Ni committed
669
* __nnictl package install__
670
671
672
673
674
675
676
677
678
679
680
681
  * Description

    Install the packages needed in nni experiments.

  * Usage

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

  * Options

Chi Song's avatar
Chi Song committed
682
683
684
  |Name, shorthand|Required|Default|Description|
  |------|------|------ |------|
  |--name|  True| |The name of package to be installed|
Yan Ni's avatar
Yan Ni committed
685

686
687
688
689
690
691
692
693
  * Example

    > Install the packages needed in tuner SMAC

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

Yan Ni's avatar
Yan Ni committed
694
* __nnictl package show__
695
696
697
698
699
700
701
702
703
704
705
706

  * Description

    List the packages supported.

  * Usage

    ```bash
    nnictl package show
    ```

<a name="version"></a>
707
708

![](https://placehold.it/15/1589F0/000000?text=+) `Check NNI version`
709
710
711
712
713
714
715
716
717
718
719

* __nnictl --version__

  * Description

    Describe the current version of NNI installed.

  * Usage

    ```bash
    nnictl --version
720
    ```
721