Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Update docs to v2 config #3966

Merged
merged 3 commits into from
Jul 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 15 additions & 26 deletions docs/en_US/TrainingService/AMLMode.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,39 +46,28 @@ Use ``examples/trials/mnist-pytorch`` as an example. The NNI config YAML file's

.. code-block:: yaml

authorName: default
experimentName: example_mnist
searchSpaceFile: search_space.json
trialCommand: python3 mnist.py
trialConcurrency: 1
maxExecDuration: 1h
maxTrialNum: 10
trainingServicePlatform: aml
searchSpacePath: search_space.json
#choice: true, false
useAnnotation: false
maxTrialNumber: 10
tuner:
#choice: TPE, Random, Anneal, Evolution, BatchTuner, MetisTuner, GPTuner
#SMAC (SMAC should be installed through nnictl)
builtinTunerName: TPE
name: TPE
classArgs:
#choice: maximize, minimize
optimize_mode: maximize
trial:
command: python3 mnist.py
codeDir: .
image: msranni/nni
gpuNum: 1
amlConfig:
subscriptionId: ${replace_to_your_subscriptionId}
resourceGroup: ${replace_to_your_resourceGroup}
workspaceName: ${replace_to_your_workspaceName}
computeTarget: ${replace_to_your_computeTarget}
trainingService:
platform: aml
dockerImage: msranni/nni
subscriptionId: ${your subscription ID}
resourceGroup: ${your resource group}
workspaceName: ${your workspace name}
computeTarget: ${your compute target}

Note: You should set ``trainingServicePlatform: aml`` in NNI config YAML file if you want to start experiment in aml mode.
Note: You should set ``platform: aml`` in NNI config YAML file if you want to start experiment in aml mode.

Compared with `LocalMode <LocalMode.rst>`__ trial configuration in aml mode have these additional keys:
Compared with `LocalMode <LocalMode.rst>`__ training service configuration in aml mode have these additional keys:


* image
* dockerImage

* required key. The docker image name used in job. NNI support image ``msranni/nni`` for running aml jobs.

Expand All @@ -103,7 +92,7 @@ amlConfig:

* required key, the compute cluster name you want to use in your AML workspace. `refer <https://docs.microsoft.com/en-us/azure/machine-learning/concept-compute-target>`__ See Step 6.

* maxTrialNumPerGpu
* maxTrialNumberPerGpu

* optional key, default 1. Used to specify the max concurrency trial number on a GPU device.

Expand Down
77 changes: 27 additions & 50 deletions docs/en_US/TrainingService/LocalMode.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ In this tutorial, we will use the example in [nni/examples/trials/mnist-pytorch]
Before starts


You have an implementation for MNIST classifer using convolutional layers, the Python code is in ``mnist_before.py``.
You have an implementation for MNIST classifer using convolutional layers, the Python code is similar to ``mnist.py``.

..

Expand Down Expand Up @@ -37,15 +37,13 @@ to get hyper-parameters' values assigned by tuner. ``tuner_params`` is an object

1.3 Report NNI results: Use the API: ``nni.report_intermediate_result(accuracy)`` to send ``accuracy`` to assessor. Use the API: ``nni.report_final_result(accuracy)`` to send `accuracy` to tuner.

We had made the changes and saved it to ``mnist.py``.

**NOTE**\ :

.. code-block:: bash

accuracy - The `accuracy` could be any python object, but if you use NNI built-in tuner/assessor, `accuracy` should be a numerical variable (e.g. float, int).
assessor - The assessor will decide which trial should early stop based on the history performance of trial (intermediate result of one trial).
tuner - The tuner will generate next parameters/architecture based on the explore history (final result of all trials).
assessor - The assessor will decide which trial should early stop based on the history performance of trial (intermediate result of one trial).

..

Expand All @@ -71,16 +69,6 @@ Refer to `define search space <../Tutorial/SearchSpaceSpec.rst>`__ to learn more

..

3.1 enable NNI API mode


To enable NNI API mode, you need to set useAnnotation to *false* and provide the path of SearchSpace file (you just defined in step 1):

.. code-block:: bash

useAnnotation: false
searchSpacePath: /path/to/your/search_space.json

To run an experiment in NNI, you only needed:


Expand All @@ -96,11 +84,11 @@ To run an experiment in NNI, you only needed:
You can download nni source code and a set of examples can be found in ``nni/examples``, run ``ls nni/examples/trials`` to see all the trial examples.


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:
Let's use a simple trial example, e.g. mnist, provided by NNI. After you cloned NNI source, 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:

.. code-block:: bash

python ~/nni/examples/trials/mnist-annotation/mnist.py
python ~/nni/examples/trials/mnist-pytorch/mnist.py


This command will be filled in the YAML configure file below. Please refer to `here <../TrialExample/Trials.rst>`__ for how to write your own trial.
Expand All @@ -110,53 +98,42 @@ This command will be filled in the YAML configure file below. Please refer to `h
.. code-block:: bash

tuner:
builtinTunerName: TPE
name: TPE
classArgs:
optimize_mode: maximize


*builtinTunerName* is used to specify a tuner in NNI, *classArgs* are the arguments pass to the tuner (the spec of builtin tuners can be found `here <../Tuner/BuiltinTuner.rst>`__\ ), *optimization_mode* is to indicate whether you want to maximize or minimize your trial's result.
*name* is used to specify a tuner in NNI, *classArgs* are the arguments pass to the tuner (the spec of builtin tuners can be found `here <../Tuner/BuiltinTuner.rst>`__\ ), *optimization_mode* is to indicate whether you want to maximize or minimize your trial's result.

**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:
**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-pytorch/config.yml`` to see it. Its content is basically shown below:

.. code-block:: yaml

authorName: your_name
experimentName: auto_mnist

# how many trials could be concurrently running
trialConcurrency: 1
experimentName: local training service example

# maximum experiment running duration
maxExecDuration: 3h
searchSpaceFile ~/nni/examples/trials/mnist-pytorch/search_space.json
trailCommand: python3 mnist.py
trialCodeDirectory: ~/nni/examples/trials/mnist-pytorch

# empty means never stop
maxTrialNum: 100

# choice: local, remote
trainingServicePlatform: local
trialGpuNumber: 0
trialConcurrency: 1
maxExperimentDuration: 3h
maxTrialNumber: 10

# search space file
searchSpacePath: search_space.json
trainingService:
platform: local

# choice: true, false
useAnnotation: true
tuner:
builtinTunerName: TPE
name: TPE
classArgs:
optimize_mode: maximize
trial:
command: python mnist.py
codeDir: ~/nni/examples/trials/mnist-annotation
gpuNum: 0

Here *useAnnotation* is true because this trial example uses our python annotation (refer to `here <../Tutorial/AnnotationSpec.rst>`__ 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.

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

.. code-block:: bash

nnictl create --config ~/nni/examples/trials/mnist-annotation/config.yml
nnictl create --config ~/nni/examples/trials/mnist-pytorch/config.yml


You can refer to `here <../Tutorial/Nnictl.rst>`__ for more usage guide of *nnictl* command line tool.
Expand All @@ -169,29 +146,29 @@ The experiment has been running now. Other than *nnictl*\ , NNI also provides We
Using multiple local GPUs to speed up search
--------------------------------------------

The following steps assume that you have 4 NVIDIA GPUs installed at local and `tensorflow with GPU support <https://www.tensorflow.org/install/gpu>`__. The demo enables 4 concurrent trail jobs and each trail job uses 1 GPU.
The following steps assume that you have 4 NVIDIA GPUs installed at local and PyTorch with CUDA support. The demo enables 4 concurrent trail jobs and each trail job uses 1 GPU.

**Prepare configure file**\ : NNI provides a demo configuration file for the setting above, ``cat ~/nni/examples/trials/mnist-annotation/config_gpu.yml`` to see it. The trailConcurrency and gpuNum are different from the basic configure file:
**Prepare configure file**\ : NNI provides a demo configuration file for the setting above, ``cat ~/nni/examples/trials/mnist-pytorch/config_detailed.yml`` to see it. The trailConcurrency and trialGpuNumber are different from the basic configure file:

.. code-block:: bash

...

# how many trials could be concurrently running
trialGpuNumber: 1
trialConcurrency: 4

...

trial:
command: python mnist.py
codeDir: ~/nni/examples/trials/mnist-annotation
gpuNum: 1
trainingService:
platform: local
useActiveGpu: false # set to "true" if you are using graphical OS like Windows 10 and Ubuntu desktop


We can run the experiment with the following command:

.. code-block:: bash

nnictl create --config ~/nni/examples/trials/mnist-annotation/config_gpu.yml
nnictl create --config ~/nni/examples/trials/mnist-pytorch/config_detailed.yml


You can use *nnictl* command line tool or WebUI to trace the training progress. *nvidia_smi* command line tool can also help you to monitor the GPU usage during training.
Loading