GetStarted.md 4.23 KB
Newer Older
Scarlett Li's avatar
Scarlett Li committed
1
**Get Started with NNI**
Deshui Yu's avatar
Deshui Yu committed
2
3
===

4
## **Installation**
Chi Song's avatar
Chi Song committed
5

6
* __Dependencies__
7

Chi Song's avatar
Chi Song committed
8
9
10
11
12
13
14
  ```bash
  python >= 3.5
  git
  wget
  ```

  python pip should also be correctly installed. You could use "python3 -m pip -v" to check in Linux.
15

Chi Song's avatar
Chi Song committed
16
  * Note: we don't support virtual environment in current releases.
Deshui Yu's avatar
Deshui Yu committed
17

18
* __Install NNI through pip__
Deshui Yu's avatar
Deshui Yu committed
19

Chi Song's avatar
Chi Song committed
20
21
22
  ```bash
  python3 -m pip install --user --upgrade nni
  ```
23
24

* __Install NNI through source code__
Chi Song's avatar
Chi Song committed
25
26

  ```bash
fishyds's avatar
fishyds committed
27
  git clone -b v0.5 https://github.com/Microsoft/nni.git
Chi Song's avatar
Chi Song committed
28
29
30
  cd nni
  source install.sh
  ```
Deshui Yu's avatar
Deshui Yu committed
31
32

## **Quick start: run a customized experiment**
Chi Song's avatar
Chi Song committed
33

Deshui Yu's avatar
Deshui Yu committed
34
35
36
37
38
39
40
An experiment is to run multiple trial jobs, each trial job tries a configuration which includes a specific neural architecture (or model) and hyper-parameter values. To run an experiment through NNI, you should:

* Provide a runnable trial
* Provide or choose a tuner
* Provide a yaml experiment configure file
* (optional) Provide or choose an assessor

41
**Prepare trial**: Let's use a simple trial example, e.g. mnist, provided by NNI. After you installed NNI, NNI examples have been put in ~/nni/examples, run `ls ~/nni/examples/trials` to see all the trial examples. You can simply execute the following command to run the NNI mnist example: 
Deshui Yu's avatar
Deshui Yu committed
42

Chi Song's avatar
Chi Song committed
43
44
45
```bash
python3 ~/nni/examples/trials/mnist-annotation/mnist.py
```
Deshui Yu's avatar
Deshui Yu committed
46

47
This command will be filled in the yaml configure file below. Please refer to [here](howto_1_WriteTrial.md) for how to write your own trial.
Deshui Yu's avatar
Deshui Yu committed
48

49
**Prepare tuner**: NNI supports several popular automl algorithms, including Random Search, Tree of Parzen Estimators (TPE), Evolution algorithm etc. Users can write their own tuner (refer to [here](howto_2_CustomizedTuner.md), but for simplicity, here we choose a tuner provided by NNI as below:
Deshui Yu's avatar
Deshui Yu committed
50

Chi Song's avatar
Chi Song committed
51
52
53
54
55
56
```yaml
tuner:
  builtinTunerName: TPE
    classArgs:
      optimize_mode: maximize
```
Deshui Yu's avatar
Deshui Yu committed
57

58
*builtinTunerName* is used to specify a tuner in NNI, *classArgs* are the arguments pass to the tuner, *optimization_mode* is to indicate whether you want to maximize or minimize your trial's result.
Deshui Yu's avatar
Deshui Yu committed
59

60
**Prepare configure file**: Since you have already known which trial code you are going to run and which tuner you are going to use, it is time to prepare the yaml configure file. NNI provides a demo configure file for each trial example, `cat ~/nni/examples/trials/mnist-annotation/config.yml` to see it. Its content is basically shown below:
Deshui Yu's avatar
Deshui Yu committed
61

Chi Song's avatar
Chi Song committed
62
```yaml
Deshui Yu's avatar
Deshui Yu committed
63
64
authorName: your_name
experimentName: auto_mnist
65

Deshui Yu's avatar
Deshui Yu committed
66
67
# how many trials could be concurrently running
trialConcurrency: 2
68

Deshui Yu's avatar
Deshui Yu committed
69
70
# maximum experiment running duration
maxExecDuration: 3h
71

Deshui Yu's avatar
Deshui Yu committed
72
73
# empty means never stop
maxTrialNum: 100
74

SparkSnail's avatar
SparkSnail committed
75
# choice: local, remote, pai
Deshui Yu's avatar
Deshui Yu committed
76
trainingServicePlatform: local
77

Deshui Yu's avatar
Deshui Yu committed
78
79
80
# choice: true, false  
useAnnotation: true
tuner:
81
82
83
  builtinTunerName: TPE
  classArgs:
    optimize_mode: maximize
Deshui Yu's avatar
Deshui Yu committed
84
trial:
85
86
87
  command: python mnist.py
  codeDir: ~/nni/examples/trials/mnist-annotation
  gpuNum: 0
Chi Song's avatar
Chi Song committed
88
```
Deshui Yu's avatar
Deshui Yu committed
89

QuanluZhang's avatar
QuanluZhang committed
90
Here *useAnnotation* is true because this trial example uses our python annotation (refer to [here](../tools/annotation/README.md) for details). For trial, we should provide *trialCommand* which is the command to run the trial, provide *trialCodeDir* where the trial code is. The command will be executed in this directory. We should also provide how many GPUs a trial requires.
Deshui Yu's avatar
Deshui Yu committed
91
92
93

With all these steps done, we can run the experiment with the following command:

94
      nnictl create --config ~/nni/examples/trials/mnist-annotation/config.yml
Deshui Yu's avatar
Deshui Yu committed
95
96
97
98
99
100

You can refer to [here](NNICTLDOC.md) for more usage guide of *nnictl* command line tool.

## View experiment results
The experiment has been running now, NNI provides WebUI for you to view experiment progress, to control your experiment, and some other appealing features. The WebUI is opened by default by `nnictl create`.

101
## Read more
Chi Song's avatar
Chi Song committed
102

xuehui's avatar
xuehui committed
103
* [Tuners supported in the latest NNI release](./HowToChooseTuner.md)
Scarlett Li's avatar
Scarlett Li committed
104
* [Overview](Overview.md)
105
* [Installation](Installation.md)
Scarlett Li's avatar
Scarlett Li committed
106
107
108
109
110
111
112
* [Use command line tool nnictl](NNICTLDOC.md)
* [Use NNIBoard](WebUI.md)
* [Define search space](SearchSpaceSpec.md)
* [Config an experiment](ExperimentConfig.md)
* [How to run an experiment on local (with multiple GPUs)?](tutorial_1_CR_exp_local_api.md)
* [How to run an experiment on multiple machines?](tutorial_2_RemoteMachineMode.md)
* [How to run an experiment on OpenPAI?](PAIMode.md)
chicm-ms's avatar
chicm-ms committed
113
* [How to create a multi-phase experiment](multiPhase.md)