Hyperparameter Tuning with NNI
Introduction
This tutorial demonstrates how to use NNI (an open-source tool from Microsoft) for Hyperparameter Tuning on Neu.ro. You will create a new Neu.ro project, integrate it with NNI and run multiple tuning workers to speed up the search process.
Before moving forward with the tutorial, make sure you have Neu.ro CLI and cookiecutter installed.
Creating a Neu.ro project
To create a new Neu.ro project, run:
Populating the Experiment Code and Integrating With Neu.ro
We're going to use this NNI example code with a MNIST dataset. Put the mnist.py file to the modules
folder and search_space.json to the config
folder.
Then, add the following lines to requirements.txt
:
We are now ready to build our image:
While Docker builds our image, we can continue setting up the NNI integration.
Add the following lines at the end of .neuro/live.yml
:
This will add some new jobs to work with NNI.
Finally, put nni-config-template.yml
and prepare-nni-config.py
to the config
folder and Makefile to the root folder of your project.
Once neuro-flow build myimage
completes, your project is ready for running on Neu.ro.
Running the Tuning Jobs
The only thing left is to run
This command will:
Run 3 worker nodes. They can be configured via
N_JOBS
in Makefile andpreset
in.neuro/live.yaml
parameters respectfully.Run the master node with the
cpu-small
preset.Auto-generate a NNI configuration file for the master node pointing at the workers.
Run the training process and automatically open the NNI web interface in your browser.
You can track experiment progress and intermediate results from this web UI. When the workers are done, you can get the final hyperparameter values and download the logs if needed.
Once you're done, you can shut down the workers and the master node by running
Last updated