"docs/source/NAS/Benchmarks.rst" did not exist on "3ec26b40afd88b8255ebc74b46f475b77aa4d19b"
ExperimentConfig.md 26 KB
Newer Older
Chi Song's avatar
Chi Song committed
1
2
# Experiment(实验)配置参考

Chi Song's avatar
Chi Song committed
3
创建 Experiment 所需要的配置文件。 配置文件的路径会传入 `nnictl` 命令。 配置文件的格式为 YAML。 本文介绍了配置文件的内容,并提供了一些示例和模板。
Chi Song's avatar
Chi Song committed
4

Chi Song's avatar
Chi Song committed
5
6
- [Experiment(实验)配置参考](#experiment-config-reference) 
  - [模板](#template)
Chi Song's avatar
Chi Song committed
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
  - [说明](#configuration-spec) 
    - [authorName](#authorname)
    - [experimentName](#experimentname)
    - [trialConcurrency](#trialconcurrency)
    - [maxExecDuration](#maxexecduration)
    - [versionCheck](#versioncheck)
    - [debug](#debug)
    - [maxTrialNum](#maxtrialnum)
    - [trainingServicePlatform](#trainingserviceplatform)
    - [searchSpacePath](#searchspacepath)
    - [useAnnotation](#useannotation)
    - [multiPhase](#multiphase)
    - [multiThread](#multithread)
    - [nniManagerIp](#nnimanagerip)
    - [logDir](#logdir)
    - [logLevel](#loglevel)
    - [logCollection](#logcollection)
    - [tuner](#tuner) 
      - [builtinTunerName](#builtintunername)
      - [codeDir](#codedir)
      - [classFileName](#classfilename)
      - [className](#classname)
      - [classArgs](#classargs)
      - [gpuIndices](#gpuindices)
      - [includeIntermediateResults](#includeintermediateresults)
    - [assessor](#assessor) 
      - [builtinAssessorName](#builtinassessorname)
      - [codeDir](#codedir-1)
      - [classFileName](#classfilename-1)
      - [className](#classname-1)
      - [classArgs](#classargs-1)
    - [advisor](#advisor) 
      - [builtinAdvisorName](#builtinadvisorname)
      - [codeDir](#codedir-2)
      - [classFileName](#classfilename-2)
      - [className](#classname-2)
      - [classArgs](#classargs-2)
      - [gpuIndices](#gpuindices-1)
    - [trial](#trial)
    - [localConfig](#localconfig) 
      - [gpuIndices](#gpuindices-2)
      - [maxTrialNumPerGpu](#maxtrialnumpergpu)
      - [useActiveGpu](#useactivegpu)
    - [machineList](#machinelist) 
      - [ip](#ip)
      - [port](#port)
      - [username](#username)
      - [passwd](#passwd)
      - [sshKeyPath](#sshkeypath)
      - [passphrase](#passphrase)
      - [gpuIndices](#gpuindices-3)
      - [maxTrialNumPerGpu](#maxtrialnumpergpu-1)
      - [useActiveGpu](#useactivegpu-1)
    - [kubeflowConfig](#kubeflowconfig) 
      - [operator](#operator)
      - [storage](#storage)
      - [nfs](#nfs)
      - [keyVault](#keyvault)
      - [azureStorage](#azurestorage)
      - [uploadRetryCount](#uploadretrycount)
    - [paiConfig](#paiconfig) 
      - [userName](#username)
      - [password](#password)
      - [token](#token)
      - [host](#host)
Chi Song's avatar
Chi Song committed
72
  - [示例](#examples) 
Chi Song's avatar
Chi Song committed
73
74
75
76
77
    - [本机模式](#local-mode)
    - [远程模式](#remote-mode)
    - [PAI 模式](#pai-mode)
    - [Kubeflow 模式](#kubeflow-mode)
    - [Kubeflow 中使用 Azure 存储](#kubeflow-with-azure-storage)
Chi Song's avatar
Chi Song committed
78
79
80

## 模板

Chi Song's avatar
Chi Song committed
81
- **简化版(不包含 Annotation(标记)和 Assessor)**
Chi Song's avatar
Chi Song committed
82
83

```yaml
Chi Song's avatar
Chi Song committed
84
85
86
87
88
authorName:
experimentName:
trialConcurrency:
maxExecDuration:
maxTrialNum:
Chi Song's avatar
Chi Song committed
89
# 可选项: local, remote, pai, kubeflow
Chi Song's avatar
Chi Song committed
90
91
trainingServicePlatform:
searchSpacePath:
Chi Song's avatar
Chi Song committed
92
# 可选项: true, false, 默认值: false
Chi Song's avatar
Chi Song committed
93
useAnnotation:
Chi Song's avatar
Chi Song committed
94
# 可选项: true, false, 默认值: false
Chi Song's avatar
Chi Song committed
95
multiPhase:
Chi Song's avatar
Chi Song committed
96
# 可选项: true, false, 默认值: false
Chi Song's avatar
Chi Song committed
97
multiThread:
Chi Song's avatar
Chi Song committed
98
tuner:
Chi Song's avatar
Chi Song committed
99
  # 可选项: TPE, Random, Anneal, Evolution
Chi Song's avatar
Chi Song committed
100
101
  builtinTunerName:
  classArgs:
Chi Song's avatar
Chi Song committed
102
    # 可选项: maximize, minimize
Chi Song's avatar
Chi Song committed
103
    optimize_mode:
Chi Song's avatar
Chi Song committed
104
  gpuIndices:
Chi Song's avatar
Chi Song committed
105
trial:
Chi Song's avatar
Chi Song committed
106
107
108
  command:
  codeDir:
  gpuNum:
Chi Song's avatar
Chi Song committed
109
# 在本机模式下,machineList 可为空
Chi Song's avatar
Chi Song committed
110
machineList:
Chi Song's avatar
Chi Song committed
111
112
113
  - ip:
    port:
    username:
Chi Song's avatar
Chi Song committed
114
115
116
    passwd:
```

Chi Song's avatar
Chi Song committed
117
- **使用 Assessor**
Chi Song's avatar
Chi Song committed
118
119
120
121
122
123
124
125
126
127

```yaml
authorName: 
experimentName: 
trialConcurrency: 
maxExecDuration: 
maxTrialNum: 
#可选项: local, remote, pai, kubeflow
trainingServicePlatform: 
searchSpacePath: 
Chi Song's avatar
Chi Song committed
128
129
130
131
132
133
#可选项: true, false, 默认值: false
useAnnotation:
#可选项: true, false, 默认值: false
multiPhase:
#可选项: true, false, 默认值: false
multiThread:
Chi Song's avatar
Chi Song committed
134
135
136
137
138
139
tuner:
  #可选项: TPE, Random, Anneal, Evolution
  builtinTunerName:
  classArgs:
    #可选项: maximize, minimize
    optimize_mode:
Chi Song's avatar
Chi Song committed
140
  gpuIndices: 
Chi Song's avatar
Chi Song committed
141
142
143
144
145
146
assessor:
  #可选项: Medianstop
  builtinAssessorName:
  classArgs:
    #可选项: maximize, minimize
    optimize_mode:
Chi Song's avatar
Chi Song committed
147
  gpuIndices: 
Chi Song's avatar
Chi Song committed
148
149
150
trial:
  command: 
  codeDir: 
Chi Song's avatar
Chi Song committed
151
  gpuIndices: 
Chi Song's avatar
Chi Song committed
152
153
154
155
156
157
158
159
#在本地使用时,machineList 可为空
machineList:
  - ip: 
    port: 
    username: 
    passwd:
```

Chi Song's avatar
Chi Song committed
160
- **使用 Annotation**
Chi Song's avatar
Chi Song committed
161
162
163
164
165
166
167
168
169

```yaml
authorName: 
experimentName: 
trialConcurrency: 
maxExecDuration: 
maxTrialNum: 
#可选项: local, remote, pai, kubeflow
trainingServicePlatform: 
Chi Song's avatar
Chi Song committed
170
171
172
173
174
175
#可选项: true, false, 默认值: false
useAnnotation:
#可选项: true, false, 默认值: false
multiPhase:
#可选项: true, false, 默认值: false
multiThread:
Chi Song's avatar
Chi Song committed
176
177
178
179
180
181
tuner:
  #可选项: TPE, Random, Anneal, Evolution
  builtinTunerName:
  classArgs:
    #可选项: maximize, minimize
    optimize_mode:
Chi Song's avatar
Chi Song committed
182
  gpuIndices: 
Chi Song's avatar
Chi Song committed
183
184
185
186
187
188
assessor:
  #可选项: Medianstop
  builtinAssessorName:
  classArgs:
    #可选项: maximize, minimize
    optimize_mode:
Chi Song's avatar
Chi Song committed
189
  gpuIndices: 
Chi Song's avatar
Chi Song committed
190
191
192
trial:
  command: 
  codeDir: 
Chi Song's avatar
Chi Song committed
193
  gpuIndices: 
Chi Song's avatar
Chi Song committed
194
195
196
197
198
199
200
201
202
203
#在本地使用时,machineList 可为空
machineList:
  - ip: 
    port: 
    username: 
    passwd:
```

## 说明

Chi Song's avatar
Chi Song committed
204
### authorName
Chi Song's avatar
Chi Song committed
205

Chi Song's avatar
Chi Song committed
206
必填。 字符串。
Chi Song's avatar
Chi Song committed
207

Chi Song's avatar
Chi Song committed
208
创建 Experiment 的作者的姓名。
Chi Song's avatar
Chi Song committed
209

Chi Song's avatar
Chi Song committed
210
*待定: 增加默认值。*
Chi Song's avatar
Chi Song committed
211

Chi Song's avatar
Chi Song committed
212
### experimentName
Chi Song's avatar
Chi Song committed
213

Chi Song's avatar
Chi Song committed
214
必填。 字符串。
Chi Song's avatar
Chi Song committed
215

Chi Song's avatar
Chi Song committed
216
创建的 Experiment 名称。
Chi Song's avatar
Chi Song committed
217

Chi Song's avatar
Chi Song committed
218
*待定: 增加默认值。*
Chi Song's avatar
Chi Song committed
219

Chi Song's avatar
Chi Song committed
220
### trialConcurrency
Chi Song's avatar
Chi Song committed
221

Chi Song's avatar
Chi Song committed
222
必填。 1 到 99999 之间的整数。
Chi Song's avatar
Chi Song committed
223

Chi Song's avatar
Chi Song committed
224
指定同时运行的 Trial 任务的最大数量。
Chi Song's avatar
Chi Song committed
225

Chi Song's avatar
Chi Song committed
226
如果 trialGpuNum 大于空闲的 GPU 数量,并且并发的 Trial 任务数量还没达到 **trialConcurrency**,Trial 任务会被放入队列,等待分配 GPU 资源。
Chi Song's avatar
Chi Song committed
227

Chi Song's avatar
Chi Song committed
228
### maxExecDuration
Chi Song's avatar
Chi Song committed
229

Chi Song's avatar
Chi Song committed
230
可选。 字符串。 默认值:999d。
Chi Song's avatar
Chi Song committed
231

Chi Song's avatar
Chi Song committed
232
**maxExecDuration** 指定实验的最大执行时间。 时间的单位为 {**s**, **m**, **h**, **d**},其分别表示 {*秒*, *分钟*, *小时*, *天*}。
Chi Song's avatar
Chi Song committed
233

Chi Song's avatar
Chi Song committed
234
注意:maxExecDuration 设置的是 Experiment 执行的时间,不是 Trial 的。 如果 Experiment 达到了设置的最大时间,Experiment 不会停止,但不会再启动新的 Trial 作业。
Chi Song's avatar
Chi Song committed
235

Chi Song's avatar
Chi Song committed
236
### versionCheck
Chi Song's avatar
Chi Song committed
237

Chi Song's avatar
Chi Song committed
238
可选。 布尔。 默认值:false。
Chi Song's avatar
Chi Song committed
239

Chi Song's avatar
Chi Song committed
240
NNI 会校验 remote, pai 和 Kubernetes 模式下 NNIManager 与 trialKeeper 进程的版本。 如果需要禁用版本校验,versionCheck 应设置为 false。
Chi Song's avatar
Chi Song committed
241

Chi Song's avatar
Chi Song committed
242
### debug
Chi Song's avatar
Chi Song committed
243

Chi Song's avatar
Chi Song committed
244
可选。 布尔。 默认值:false。
Chi Song's avatar
Chi Song committed
245

Chi Song's avatar
Chi Song committed
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
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
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
调试模式会将 versionCheck 设置为 False,并将 logLevel 设置为 'debug'。

### maxTrialNum

可选。 1 到 99999 之间的整数。 默认值:99999。

指定 NNI 创建的最大 Trial 任务数,包括成功和失败的任务。

### trainingServicePlatform

必填。 字符串。

指定运行 Experiment 的平台,包括 **local**, **remote**, **pai**, **kubeflow**, **frameworkcontroller**.

- **local** 在本机的 Ubuntu 上运行 Experiment。

- **remote** 将任务提交到远程的 Ubuntu 上,必须用 **machineList** 来指定远程的 SSH 连接信息。

- **pai** 提交任务到微软开源的 [OpenPAI](https://github.com/Microsoft/pai) 上。 更多 OpenPAI 配置,参考 [PAI 模式](../TrainingService/PaiMode.md)

- **kubeflow** 提交任务至 [Kubeflow](https://www.kubeflow.org/docs/about/kubeflow/)。 NNI 支持基于 Kubeflow 的 Kubenetes,以及[Azure Kubernetes](https://azure.microsoft.com/en-us/services/kubernetes-service/)。 详情参考 [Kubeflow 文档](../TrainingService/KubeflowMode.md)

- TODO:解释 FrameworkController。

### searchSpacePath

可选。 现有文件的路径。

指定搜索空间文件的路径,此文件必须在运行 nnictl 的本机。

仅在 `useAnnotation=True` 时,才不需要填写 **searchSpacePath**

### useAnnotation

可选。 布尔。 默认值:false。

使用 Annotation 分析 Trial 代码并生成搜索空间。

注意:如果 **useAnnotation** 为 true,searchSpacePath 字段会被删除。

### multiPhase

可选。 布尔。 默认值:false。

启用[多阶段 Experiment](../AdvancedFeature/MultiPhase.md)

### multiThread

可选。 布尔。 默认值:false。

为 Dispatcher 启用多线程模式。 如果启用了 multiThread,Dispatcher 将启动一个线程来处理来自 NNI 管理器的每个命令。

### nniManagerIp

可选。 字符串。 默认值:eth0 设备的 IP。

设置运行 NNI 管理器进程的计算机的 IP 地址。 此字段为可选项,如果没有设置,则会使用 eth0 的 IP 地址。

注意: 可在 NNI 管理器机器上运行 `ifconfig` 来检查 eth0 是否存在。 如果没有,建议显式设置 **nniManagerIp**

### logDir

可选。 目录的路径。 默认值:`<user home directory>/nni/experiment`

配置目录以存储 Experiment 的日志和数据。

### logLevel

可选。 字符串。 默认值:`info`

设置 Experiment 的日志级别。 可设置的日志级别包括:`trace`, `debug`, `info`, `warning`, `error`, `fatal`

### logCollection

可选。 `http``none`。 默认值:`none`

设置在remote、pai、kubeflow、frameworkcontroller 平台中收集日志的方式。 日志支持两种设置,一种是通过 `http`,让 Trial 将日志通过 POST 方法发回日志,这种方法会减慢 trialKeeper 的速度。 另一种方法是 `none`,Trial 不将日志回传回来,仅仅回传 Job 的指标。 如果日志较大,可将此参数设置为 `none`

### tuner

必填。

指定了 Experiment 的 Tuner 算法。有两种方法可设置 Tuner。 一种方法是使用 NNI SDK 提供的内置 Tuner,在这种情况下,需要设置 **builtinTunerName****classArgs**。 另一种方法,是使用用户自定义的 Tuner,需要设置 **codeDirectory****classFileName****className****classArgs***必须选择其中的一种方式。*

#### builtinTunerName

如果使用内置 Tuner,则为必需。 字符串。

指定系统 Tuner 的名称, NNI SDK 提供的各种 Tuner 的[说明](../Tuner/BuiltinTuner.md)

#### codeDir

如果使用定制 Tuner,则为必需。 相对于配置文件位置的路径。

指定 Tuner 代码的目录。

#### classFileName

如果使用定制 Tuner,则为必需。 相对于 **codeDir** 的文件路径。

指定 Tuner 文件的名称。

#### className

如果使用定制 Tuner,则为必需。 字符串。

指定 Tuner 的名称。

#### classArgs

可选。 键值对。 默认值:空。

指定 Tuner 算法的参数。 参考[此文件](../Tuner/BuiltinTuner.md)来了解内置 Tuner 的配置参数。

#### gpuIndices

可选。 字符串。 默认值:空。

指定 Tuner 进程可以使用的 GPU。 可以指定单个或多个 GPU 索引。 多个 GPU 索引用逗号 `,` 分隔。 例如,`1``0,1,3`。 如果未设置该字段,则 Tuner 将找不到 GPU(设置 `CUDA_VISIBLE_DEVICES` 成空字符串)。

#### includeIntermediateResults

可选。 布尔。 默认值:false。

如果 **includeIntermediateResults** 为 true,最后一个 Assessor 的中间结果会被发送给 Tuner 作为最终结果。

### assessor

指定 Assessor 算法以运行 Experiment。 与 Tuner 类似,有两种设置 Assessor 的方法。 一种方法是使用 NNI SDK 提供的 Assessor。 用户需要设置 **builtinAssessorName****classArgs**。 另一种方法,是使用自定义的 Assessor,需要设置 **codeDirectory****classFileName****className****classArgs***必须选择其中的一种方式。*

默认情况下,未启用任何 Assessor。

#### builtinAssessorName

如果使用内置 Assessor,则为必需。 字符串。

指定内置 Assessor 的名称,NNI SDK 提供的 Assessor 可参考[这里](../Assessor/BuiltinAssessor.md)

#### codeDir

如果使用定制 Assessor,则为必需。 相对于配置文件位置的路径。

指定 Assessor 代码的目录。

#### classFileName

如果使用定制 Assessor,则为必需。 相对于 **codeDir** 的文件路径。

指定 Assessor 文件的名称。

#### className

如果使用定制 Assessor,则为必需。 字符串。

指定 Assessor 类的名称。

#### classArgs

可选。 键值对。 默认值:空。

指定 Assessor 算法的参数。

### advisor

可选。

指定 Experiment 中的 Advisor 算法。 与 Tuner 和 Assessor 类似,有两种指定 Advisor 的方法。 一种方法是使用 SDK 提供的 Advisor ,需要设置 **builtinAdvisorName****classArgs**。 另一种方法,是使用用户自定义的 Advisor,需要设置 **codeDirectory****classFileName****className****classArgs**

启用 Advisor 后,将忽略 Tuner 和 Advisor 的设置。

#### builtinAdvisorName

指定内置 Advisor 的名称。 NNI SDK 提供了 [BOHB](../Tuner/BohbAdvisor.md)[Hyperband](../Tuner/HyperbandAdvisor.md)

#### codeDir

如果使用定制 Advisor,则为必需。 相对于配置文件位置的路径。

指定 Advisor 代码的目录。

#### classFileName

如果使用定制 Advisor,则为必需。 相对于 **codeDir** 的文件路径。

指定 Advisor 文件的名称。

#### className

如果使用定制 Advisor,则为必需。 字符串。

指定 Advisor 类的名称。

#### classArgs

可选。 键值对。 默认值:空。

指定 Advisor 的参数。

#### gpuIndices

可选。 字符串。 默认值:空。

指定可以使用的 GPU。 可以指定单个或多个 GPU 索引。 多个 GPU 索引用逗号 `,` 分隔。 例如,`1``0,1,3`。 如果未设置该字段,则 Tuner 将找不到 GPU(设置 `CUDA_VISIBLE_DEVICES` 成空字符串)。

### trial

必填。 键值对。

在 local 和 remote 模式下,需要以下键。

- **command**:必需字符串。 指定运行 Trial 的命令。

- **codeDir**:必需字符串。 指定 Trial 文件的目录。 此目录将在 remote 模式下自动上传。

- **gpuNum**:可选、整数。 指定了运行 Trial 进程的 GPU 数量。 默认值为 0。

在 PAI 模式下,需要以下键。

- **command**:必需字符串。 指定运行 Trial 的命令。

- **codeDir**:必需字符串。 指定 Trial 文件的目录。 目录中的文件将在 PAI 模式下上传。

- **gpuNum**:必需、整数。 指定了运行 Trial 进程的 GPU 数量。 默认值为 0。

- **cpuNum**:必需、整数。 指定要在 OpenPAI 容器中使用的 cpu 数。

- **memoryMB**:必需、整数。 设置要在 OpenPAI 容器中使用的内存大小,以兆字节为单位。

- **image**:必需字符串。 设置要在 OpenPAI 中使用的 Docker 映像。

- **authFile**:可选、字符串。 用于提供 Docker 注册,用于为 OpenPAI 中的映像拉取请求进行身份验证。 [参考](https://github.com/microsoft/pai/blob/2ea69b45faa018662bc164ed7733f6fdbb4c42b3/docs/faq.md#q-how-to-use-private-docker-registry-job-image-when-submitting-an-openpai-job)

- **shmMB**:可选、整数。 容器的共享内存大小。

- **portList**: `label`, `beginAt`, `portNumber` 的键值对 list。 参考[ OpenPAI Job 教程](https://github.com/microsoft/pai/blob/master/docs/job_tutorial.md)

在 Kubeflow 模式下,需要以下键。

- **codeDir** 指定了代码文件的本机路径。

- **ps**: Kubeflow 的 tensorflow-operator 的可选配置,包括:
Chi Song's avatar
Chi Song committed
487
  
Chi Song's avatar
Chi Song committed
488
      * __replicas__: __ps__ 角色的副本数量。
Chi Song's avatar
Chi Song committed
489
      
Chi Song's avatar
Chi Song committed
490
      * __command__: __ps__ 容器的运行脚本。
Chi Song's avatar
Chi Song committed
491
      
Chi Song's avatar
Chi Song committed
492
      * __gpuNum__: 在 __ps__ 容器中使用的 GPU 数量。
Chi Song's avatar
Chi Song committed
493
      
Chi Song's avatar
Chi Song committed
494
      * __cpuNum__: 在 __ps__ 容器中使用的 CPU 数量。
Chi Song's avatar
Chi Song committed
495
      
Chi Song's avatar
Chi Song committed
496
      * __memoryMB__:容器的内存大小。
Chi Song's avatar
Chi Song committed
497
      
Chi Song's avatar
Chi Song committed
498
      * __image__: 在 __ps__ 中使用的 Docker 映像。
Chi Song's avatar
Chi Song committed
499
      
Chi Song's avatar
Chi Song committed
500
501

- **worker** 是 Kubeflow 的 tensorflow-operator 的可选配置。
Chi Song's avatar
Chi Song committed
502
  
Chi Song's avatar
Chi Song committed
503
      * __replicas__: __worker__ 角色的副本数量。
Chi Song's avatar
Chi Song committed
504
      
Chi Song's avatar
Chi Song committed
505
      * __command__: __worker__ 容器的运行脚本。
Chi Song's avatar
Chi Song committed
506
      
Chi Song's avatar
Chi Song committed
507
      * __gpuNum__: 在 __worker__ 容器中使用的 GPU 数量。
Chi Song's avatar
Chi Song committed
508
      
Chi Song's avatar
Chi Song committed
509
      * __cpuNum__: 在 __worker__ 容器中使用的 CPU 数量。
Chi Song's avatar
Chi Song committed
510
      
Chi Song's avatar
Chi Song committed
511
      * __memoryMB__:容器的内存大小。
Chi Song's avatar
Chi Song committed
512
      
Chi Song's avatar
Chi Song committed
513
      * __image__: 在 __worker__ 中使用的 Docker 映像。
Chi Song's avatar
Chi Song committed
514
515
      

Chi Song's avatar
Chi Song committed
516
### localConfig
Chi Song's avatar
Chi Song committed
517

Chi Song's avatar
Chi Song committed
518
本机模式下可选。 键值对。
Chi Song's avatar
Chi Song committed
519

Chi Song's avatar
Chi Song committed
520
仅在 **trainingServicePlatform** 设为 `local` 时有效,否则,配置文件中不应该有 **localConfig** 部分。
Chi Song's avatar
Chi Song committed
521

Chi Song's avatar
Chi Song committed
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
#### gpuIndices

可选。 字符串。 默认值:none。

用于指定特定的 GPU。设置此值后,只有指定的 GPU 会被用来运行 Trial 任务。 可以指定单个或多个 GPU 索引。 多个 GPU 索引,应用逗号(`,`)分隔,如 `1``0,1,3`。 默认情况下,将使用所有可用的 GPU。

#### maxTrialNumPerGpu

可选。 整数。 默认值:99999。

用于指定 GPU 设备上的最大并发 Trial 的数量。

#### useActiveGpu

可选。 布尔。 默认值:false。

用于指定 GPU 上存在其他进程时是否使用此 GPU。 默认情况下,NNI 仅在 GPU 中没有其他活动进程时才使用 GPU。 如果 **useActiveGpu** 设置为 true,则 NNI 无论某 GPU 是否有其它进程,都将使用它。 此字段不适用于 Windows 版的 NNI。

### machineList

在 remote 模式下必需。 具有以下键的键值对的列表。

#### ip

必填。 可从当前计算机访问的 IP 地址。

远程计算机的 IP 地址。

#### port

可选。 整数。 有效端口。 默认值: 22。

用于连接计算机的 SSH 端口。

#### username

使用用户名/密码进行身份验证时是必需的。 字符串。

远程计算机的帐户。

#### passwd

使用用户名/密码进行身份验证时是必需的。 字符串。

指定帐户的密码。

#### sshKeyPath

如果使用 SSH 密钥进行身份验证,则为必需。 私钥文件的路径。

如果用户使用 SSH 密钥登录远程计算机,**sshKeyPath** 应是有效的 SSH 密钥文件路径。

*注意:如果同时设置了 passwd 和 sshKeyPath,NNI 会首先使用 passwd。*

#### passphrase

可选。 字符串。

用于保护 SSH 密钥,如果用户没有密码,可为空。

#### gpuIndices

可选。 字符串。 默认值:none。

用于指定特定的 GPU。设置此值后,只有指定的 GPU 会被用来运行 Trial 任务。 可以指定单个或多个 GPU 索引。 多个 GPU 索引,应用逗号(`,`)分隔,如 `1``0,1,3`。 默认情况下,将使用所有可用的 GPU。

#### maxTrialNumPerGpu

可选。 整数。 默认值:99999。

用于指定 GPU 设备上的最大并发 Trial 的数量。

#### useActiveGpu

可选。 布尔。 默认值:false。

用于指定 GPU 上存在其他进程时是否使用此 GPU。 默认情况下,NNI 仅在 GPU 中没有其他活动进程时才使用 GPU。 如果 **useActiveGpu** 设置为 true,则 NNI 无论某 GPU 是否有其它进程,都将使用它。 此字段不适用于 Windows 版的 NNI。

### kubeflowConfig

#### operator

必填。 字符串。 必须是 `tf-operator``pytorch-operator`

指定要使用的 Kubeflow 运算符,当前版本中 NNI 支持 `tf-operator`

#### storage

可选。 字符串。 默认值 `nfs`

指定 Kubeflow 的存储类型,包括 `nfs``azureStorage`

#### nfs

如果使用 nfs,则必需。 键值对。

- **server** 是 NFS 服务器的地址。

- **path** 是 NFS 挂载的路径。

#### keyVault

如果使用 Azure 存储,则必需。 键值对。

**keyVault** 设置为 Azure 存储帐户的私钥。 参考:https://docs.microsoft.com/en-us/azure/key-vault/key-vault-manage-with-cli2 。

- **vaultName** 是 az 命令中 `--vault-name` 的值。

- **name** 是 az 命令中 `--name` 的值。

#### azureStorage

如果使用 Azure 存储,则必需。 键值对。

设置 Azure 存储帐户以存储代码文件。

- **accountName** 是 Azure 存储账户的名称。

- **azureShare** 是 Azure 文件存储的共享参数。

#### uploadRetryCount

如果使用 Azure 存储,则必需。 1 到 99999 之间的整数。

如果上传文件至 Azure Storage 失败,NNI 会重试。此字段指定了重试的次数。

### paiConfig

#### userName

必填。 字符串。

OpenPAI 帐户的用户名。

#### password

如果使用密码身份验证,则需要。 字符串。

OpenPAI 帐户的密码。

#### token

如果使用 token 身份验证,则需要。 字符串。

可以从 OpenPAI 门户检索的个人访问 token。

#### host

必填。 字符串。

OpenPAI 的 IP 地址。

## 示例

### 本机模式

如果要在本机运行 Trial 任务,并使用标记来生成搜索空间,可参考下列配置:

    authorName: test
    experimentName: test_experiment
    trialConcurrency: 3
    maxExecDuration: 1h
    maxTrialNum: 10
    #可选项: local, remote, pai, kubeflow
    trainingServicePlatform: local
    #可选项: true, false
    useAnnotation: true
    tuner:
      #可选项: TPE, Random, Anneal, Evolution
      builtinTunerName: TPE
      classArgs:
        #可选项: maximize, minimize
        optimize_mode: maximize
    trial:
      command: python3 mnist.py
      codeDir: /nni/mnist
      gpuNum: 0
Chi Song's avatar
Chi Song committed
699
700
    

Chi Song's avatar
Chi Song committed
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
增加 Assessor 配置

    authorName: test
    experimentName: test_experiment
    trialConcurrency: 3
    maxExecDuration: 1h
    maxTrialNum: 10
    #可选项: local, remote, pai, kubeflow
    trainingServicePlatform: local
    searchSpacePath: /nni/search_space.json
    #可选项: true, false
    useAnnotation: false
    tuner:
      #可选项: TPE, Random, Anneal, Evolution
      builtinTunerName: TPE
      classArgs:
        #可选项: maximize, minimize
        optimize_mode: maximize
    assessor:
      #可选项: Medianstop
      builtinAssessorName: Medianstop
      classArgs:
        #可选项: maximize, minimize
        optimize_mode: maximize
    trial:
      command: python3 mnist.py
      codeDir: /nni/mnist
      gpuNum: 0
    
Chi Song's avatar
Chi Song committed
730

Chi Song's avatar
Chi Song committed
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
或者可以指定自定义的 Tuner 和 Assessor:

    authorName: test
    experimentName: test_experiment
    trialConcurrency: 3
    maxExecDuration: 1h
    maxTrialNum: 10
    #可选项: local, remote, pai, kubeflow
    trainingServicePlatform: local
    searchSpacePath: /nni/search_space.json
    #可选项: true, false
    useAnnotation: false
    tuner:
      codeDir: /nni/tuner
      classFileName: mytuner.py
      className: MyTuner
      classArgs:
        #可选项: maximize, minimize
        optimize_mode: maximize
    assessor:
      codeDir: /nni/assessor
      classFileName: myassessor.py
      className: MyAssessor
      classArgs:
        #choice: maximize, minimize
        optimize_mode: maximize
    trial:
Chi Song's avatar
Chi Song committed
758
      command: python3 mnist.py
Chi Song's avatar
Chi Song committed
759
      codeDir: /nni/mnist
Chi Song's avatar
Chi Song committed
760
      gpuNum: 0
Chi Song's avatar
Chi Song committed
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
    

### 远程模式

如果要在远程服务器上运行 Trial 任务,需要增加服务器信息:

    authorName: test
    experimentName: test_experiment
    trialConcurrency: 3
    maxExecDuration: 1h
    maxTrialNum: 10
    #可选项: local, remote, pai, kubeflow
    trainingServicePlatform: remote
    searchSpacePath: /nni/search_space.json
    #可选项: true, false
    useAnnotation: false
    tuner:
      #可选项: TPE, Random, Anneal, Evolution
      builtinTunerName: TPE
      classArgs:
        #可选项: maximize, minimize
        optimize_mode: maximize
    trial:
Chi Song's avatar
Chi Song committed
784
      command: python3 mnist.py
Chi Song's avatar
Chi Song committed
785
      codeDir: /nni/mnist
Chi Song's avatar
Chi Song committed
786
      gpuNum: 0
Chi Song's avatar
Chi Song committed
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
    # 如果是本地 Experiment,machineList 可为空。
    machineList:
    
      - ip: 10.10.10.10
        port: 22
        username: test
        passwd: test
      - ip: 10.10.10.11
        port: 22
        username: test
        passwd: test
      - ip: 10.10.10.12
        port: 22
        username: test
        sshKeyPath: /nni/sshkey
        passphrase: qwert
    

### OpenPAI 模式

    authorName: test
    experimentName: nni_test1
    trialConcurrency: 1
    maxExecDuration:500h
    maxTrialNum: 1
    #可选项: local, remote, pai, kubeflow
    trainingServicePlatform: pai
    searchSpacePath: search_space.json
    #可选项: true, false
    useAnnotation: false
    tuner:
      #可选项: TPE, Random, Anneal, Evolution, BatchTuner
      #SMAC (SMAC 需要使用 nnictl package 单独安装)
      builtinTunerName: TPE
      classArgs:
        #可选项: maximize, minimize
        optimize_mode: maximize
    trial:
      command: python3 main.py
      codeDir: .
      gpuNum: 4
      cpuNum: 2
      memoryMB: 10000
      # 在 OpenPAI 上运行 NNI 的 Docker 映像
Chi Song's avatar
Chi Song committed
831
      image: msranni/nni:latest
Chi Song's avatar
Chi Song committed
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
    paiConfig:
      # 登录 OpenPAI 的用户名
      userName: test
      # 登录 OpenPAI 的密码
      passWord: test
      # OpenPAI 的 RestFUL 服务器地址
      host: 10.10.10.10
    

### Kubeflow 模式

    使用 NFS 存储。
    
    authorName: default
    experimentName: example_mni
    trialConcurrency: 1
    maxExecDuration: 1h
    maxTrialNum: 1
    # 可选项: local, remote, pai, kubeflow
    trainingServicePlatform: kubeflow
    searchSpacePath: search_space.json
    # 可选项: true, false
    useAnnotation: false
    tuner:
      # 可选项: TPE, Random, Anneal, Evolution
      builtinTunerName: TPE
      classArgs:
        # 可选项: maximize, minimize
        optimize_mode: maximize
    trial:
      codeDir: .
      worker:
        replicas: 1
        command: python3 mnist.py
        gpuNum: 0
        cpuNum: 1
        memoryMB: 8192
        image: msranni/nni:latest
    kubeflowConfig:
      operator: tf-operator
      nfs:
        server: 10.10.10.10
        path: /var/nfs/general
    
    

### Kubeflow 中使用 Azure 存储

    authorName: default
    experimentName: example_mni
    trialConcurrency: 1
    maxExecDuration: 1h
    maxTrialNum: 1
    # 可选项: local, remote, pai, kubeflow
    trainingServicePlatform: kubeflow
    searchSpacePath: search_space.json
    # 可选项: true, false
    useAnnotation: false
    #nniManagerIp: 10.10.10.10
    tuner:
      # 可选项: TPE, Random, Anneal, Evolution
      builtinTunerName: TPE
      classArgs:
        # 可选项: maximize, minimize
        optimize_mode: maximize
    assessor:
      builtinAssessorName: Medianstop
      classArgs:
        optimize_mode: maximize
    trial:
      codeDir: .
      worker:
        replicas: 1
        command: python3 mnist.py
        gpuNum: 0
        cpuNum: 1
        memoryMB: 4096
        image: msranni/nni:latest
    kubeflowConfig:
      operator: tf-operator
      keyVault:
        vaultName: Contoso-Vault
        name: AzureStorageAccountKey
      azureStorage:
        accountName: storage
        azureShare: share01