<jupyter_start><jupyter_text>Running Plato in Google's Colab Notebooks 1. Preparation Use Chrome broswerSince Colab is a product from Google, to take the most advantage of it, Chrome is the most recommended broswer here. Activating GPU supportIf you need GPU support in your project, you may activate it in Google Colab by clicking on `Runtime > Change runtime type` in the notebook menu and choosing `GPU` as the hardware accelerator. To check whether the GPU is available for computation, we import the deep learning framework [PyTorch](https://pytorch.org/):<jupyter_code>import torch
torch.cuda.is_available()<jupyter_output><empty_output><jupyter_text>If successful, the output of the cell above should print `True`. Use Google DriveSince Google Colab removes all the files that you have downloaded or created when you end a session, the best option is to use GitHub to store your code, and Google Drive to store your datasets, logs, and anything else that would normally reside on your filesystem but wouldn’t be tracked by a git repo.When you run the code below, you will need to click a link and follow a process that takes a few seconds. When the process is complete, all of your drive files will be available via ‘/root/drive’ on your Colab instance, and this will allow you to structure your projects in the same way you would if you were using a cloud server.<jupyter_code>from google.colab import drive
drive.mount('/content/drive')
root_path = '/content/drive/My\ Drive'
%cd $root_path<jupyter_output><empty_output><jupyter_text>2. Installing Plato with PyTorchClone Plato's public git repository on GitHub to your Google drive.<jupyter_code>!git clone https://github.com/TL-System/plato<jupyter_output><empty_output><jupyter_text>Then install the required Python packages:<jupyter_code>!pip install -r $root_path/plato/requirements.txt -U<jupyter_output><empty_output><jupyter_text>Get into the `plato` directory:<jupyter_code>!chmod -R ugo+rx $root_path/plato/run
%cd $root_path/plato/<jupyter_output><empty_output><jupyter_text>3. Running Plato Make sure you don’t get disconnectedRun the following cell when you plan to do a long training to avoid getting disconnected in the middle of it.<jupyter_code>%%javascript
function ClickConnect(){
console.log("Working");
document.querySelector("colab-toolbar-button#connect").click()
}setInterval(ClickConnect,60000)<jupyter_output><empty_output><jupyter_text>**Note:** Please use this responsibly. Getting booted from Colab is very annoying, but it is done to make resources available for others when you’re not actively using them.   Setting up Weights and BiasesSupport for logging using Weights and Biases (https://wandb.com) is built-in. It will prompt you to enter your key when starting your first run. If you don't wish to use Weights and Biases, set it to `offline`:<jupyter_code>!wandb offline<jupyter_output><empty_output><jupyter_text>Running Plato in the Colab notebookTo start a federated learning training workload, run `run` from Plato's home directory. For example:<jupyter_code>!./run -s 127.0.0.1:8000 -c ./configs/MNIST/fedavg_lenet5.yml<jupyter_output><empty_output><jupyter_text>Here, `fedavg_lenet5.yml` is a sample configuration file that uses Federated Averaging as the federated learning algorithm, and LeNet5 as the model. Other configuration files under `plato/configs/` could also be used here.  Running Plato in a terminalIt is strongly recommended and more convenient to run Plato in a terminal, preferably in Visual Studio Code. To do this, first sign up for a free account in [ngrok](https://ngrok.com), and then use your authentication token and your account password in the following code:<jupyter_code>!pip install colab_ssh --upgrade
from getpass import getpass
ngrok_token = getpass('Your authentication token: ')
password = getpass('Your ngrok account password: ')

from colab_ssh import launch_ssh, init_git
launch_ssh(ngrok_token, password)<jupyter_output><empty_output>