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

add tutorial for colab support #2700

Merged
merged 9 commits into from
Jul 24, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
44 changes: 44 additions & 0 deletions docs/en_US/CommunitySharings/NNI_colab_support.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

# Use NNI on Google Colab
NNI can easily run on Google's colab platform. However, colab doesn't expose its public IP and ports, so by default you can not access NNI's web ui on colab. To solve this, you need a reverse proxy software like `ngrok` or `frp`. This tutorial will show you how to use ngrok to get access to NNI's web ui on colab.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use ngrok to access NNI's web ui

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.


## How to Open NNI's WebUI on Google's Colab

1. Install required packages and softwares.


```
! pip install nni # install nni
! wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip # download ngrok and unzip it
! unzip ngrok-stable-linux-amd64.zip
! mkdir -p nni_repo
! git clone https://github.com/microsoft/nni.git nni_repo/nni # clone NNI's offical repo to get examples
```

2. Register a ngrok account [here](https://ngrok.com/), then connect to your account using your authtoken.


```
! ./ngrok authtoken <your-authtoken>
```

3. Start an NNI trail example on a port greater than 1024, then start ngrok with the same port.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

greater -> bigger

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.



```
! nnictl create --config nni_repo/nni/examples/trials/mnist-pytorch/config.yml --port 5000 & # if you want to use gpu, make sure gpuNum >= 1 in config.yml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can add comments in text instead of in the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

get_ipython().system_raw('./ngrok http 5000 &')
Copy link
Contributor

@SparkSnail SparkSnail Jul 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is get_ipython()? why not use ./ngrok http 5000 & directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If use ! ./ngrok http 5000 & directly, the cell running this command will stuck. Not sure why this happened. Use get_ipython() will solve this problem.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think what get_ipython is trying to solve should be stated in tutorial.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

```

4. Check the public url.


```
! curl -s http://localhost:4040/api/tunnels # don't change the port number 4040
```

You will see an url like http://xxxx.ngrok.io after step 4, open this url and you will find NNI's web ui. Have fun :)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Web UI

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.


## Access WebUI with frp

frp is another reverse proxy software with similar functions. However, frp doesn't provide free public urls, so you may need an server with public IP as an frp server. See [here](https://github.com/fatedier/frp) to know more about how to deploy frp.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an -> a

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

1 change: 1 addition & 0 deletions docs/en_US/CommunitySharings/community_sharings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ Different from the tutorials and examples in the rest of the document which show
Model Compression <model_compression>
Feature Engineering <feature_engineering>
Performance measurement, comparison and analysis <perf_compare>
Use NNI on Google Colab <NNI_colab_support>