"src/vscode:/vscode.git/clone" did not exist on "bc8eb7c9076d598171aee37021c1feb52ba1d2ea"
InstallCustomizedTuner.md 1.87 KB
Newer Older
1
# How to register a customized tuner as a builtin tuner
chicm-ms's avatar
chicm-ms committed
2

3
You can following below steps to register a customized tuner in `nni/examples/tuners/customized_tuner` as a builtin tuner.
chicm-ms's avatar
chicm-ms committed
4

5
## Install the customized tuner package into python environment
chicm-ms's avatar
chicm-ms committed
6

7
There are 2 options to install the package into python environment:
chicm-ms's avatar
chicm-ms committed
8
9
10

### Option 1: install from directory

11
From `nni/examples/tuners/customized_tuner` directory, run:
chicm-ms's avatar
chicm-ms committed
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

`python setup.py develop`

This command will build the `nni/examples/tuners/customized_tuner` directory as a pip installation source.


### Option 2: install from whl file

Step 1: From `nni/examples/tuners/customized_tuner` directory, run:

`python setup.py bdist_wheel`

This command build a whl file which is a pip installation source.

Step 2: Run command:

28
29
30
31
32
33
34
`pip install dist/demo_tuner-0.1-py3-none-any.whl`

## Register the customized tuner as builtin tuner:

Run following command:

`nnictl algo register --meta meta_file.yml`
chicm-ms's avatar
chicm-ms committed
35

36
## Check the registered builtin algorithms
chicm-ms's avatar
chicm-ms committed
37

38
Then run command `nnictl algo list`, you should be able to see that demotuner is installed:
chicm-ms's avatar
chicm-ms committed
39
40
```
+-----------------+------------+-----------+--------=-------------+------------------------------------------+
41
|      Name       |    Type    |  source   |      Class Name      |               Module Name                |
chicm-ms's avatar
chicm-ms committed
42
+-----------------+------------+-----------+----------------------+------------------------------------------+
43
| demotuner       | tuners     |  user     | DemoTuner            | demo_tuner                               |
chicm-ms's avatar
chicm-ms committed
44
45
46
47
48
49
50
51
52
53
54
55
56
57
+-----------------+------------+-----------+----------------------+------------------------------------------+
```

## Use the installed tuner in experiment

Now you can use the demotuner in experiment configuration file the same way as other builtin tuners:

```yaml
tuner:
  builtinTunerName: demotuner
  classArgs:
    #choice: maximize, minimize
    optimize_mode: maximize
```