Coder Social home page Coder Social logo

fedml-iot's Introduction

FedML-IoT: A Federated Learning System Framework on IoT Devices

Our FedML architecture design can smoothly transplant the distributed computing code to the IoT platform.

Currently, we support two IoT devices:

1. Raspberry PI 4 (Edge CPU Computing - ARMv7l)

You can buy RPI 4 devices here: https://www.raspberrypi.org/products/raspberry-pi-4-desktop-kit/?resellerType=home

2. NVIDIA Jetson Nano (Edge GPU Computing)

About NVIDIA Jetson Nano: https://developer.nvidia.com/embedded/jetson-nano-developer-kit

NVIDIA® Jetson Nano™ Developer Kit is a small, powerful computer that lets you run multiple neural networks in parallel for applications like image classification, object detection, segmentation, and speech processing. All in an easy-to-use platform that runs in as little as 5 watts.

You can buy Jetson Nano here: https://developer.nvidia.com/buy-jetson?product=jetson_tx2&location=US

Installation

Install FedML + PyTorch 1.4 on Raspberry Pi 4

The following commands are running on Raspberry Pi 4

cd /home/pi
mkdir sourcecode
#git clone https://github.com/FedML-AI/FedML-IoT.git
git clone https://github.com/yh-yao/FedML-IoT.git
cd FedML/fedml_iot

After the above commands, please follow the script install-arm.sh.

Note: This script has been tested on Raspberry Pi 4 (RPI 4). We welcome users to contribute more scripts for new IoT platforms.

We currently support PyTorch 1.4 for Raspberry Pi 4. If you need newer verion of PyTorch, please compile the wheel file using method here: https://nmilosev.svbtle.com/compling-arm-stuff-without-an-arm-board-build-pytorch-for-the-raspberry-pi

To make sure your PyTorch + RPI environment is ready, please have a check as follows.

$ python

>>> import torch
>>> import torchvision
>>> import cv2

Install FedML + PyTorch 1.x on NVIDIA Jetson Nano

Please check here: fedml_iot/pytorch-pkg-on-jetson-nano/README.md

Prepare Dataset

cd FedML/data/MNIST/
sh download_and_unzip.sh
cd ../../../

Update the FedML library

After the clone of this repository, please run the following command to get FedML submodule to your local.

git submodule add https://github.com/yh-yao/FedML
#git submodule add https://github.com/FedML-AI/FedML
cd FedML
git submodule init
git submodule update

Log Tracking

Our log tracking platform is wandb.com. Please register your own ID and login as follows.

wandb login 007a501d8a32ad2a5701928e6789e271e9d6025c
#wandb login ee0b5f53d949c84cee7decbe7a629e63fb2f8408

Launch FedML-Server Server

FedML-IoT reuses the FedML-Server server code. So you can launch the server according to the guidance at fedml_server/executor. Please change the IP address of the server. Here, we assume the server IP is 127.0.0.1.

python app.py

The default training is MNIST (dataset) + FedAvg (optimizer) + LR (model). You can customize app.py as your need.

Launch FedML-IoT Client

Here we assume you have FOUR IoT devices. Then you can run script in each one as follows. If your RPI device has more memory, you can run multiple fedavg_rpi_client.py processes in a single device.

# for Raspberry Pi
cd ./raspberry_pi/fedavg
python fedavg_rpi_client.py --server_ip http://127.0.0.1:5000 --client_uuid '0'
python fedavg_rpi_client.py --server_ip http://127.0.0.1:5000 --client_uuid '1'
python fedavg_rpi_client.py --server_ip http://127.0.0.1:5000 --client_uuid '2'
python fedavg_rpi_client.py --server_ip http://127.0.0.1:5000 --client_uuid '3'
# for NVIDIA Jetson Nano
cd ./nvidia-jetson-nano/fedavg
python fedavg_jetson_nano_client.py --server_ip http://127.0.0.1:5000 --client_uuid '0'
python fedavg_jetson_nano_client.py --server_ip http://127.0.0.1:5000 --client_uuid '1'
python fedavg_jetson_nano_client.py --server_ip http://127.0.0.1:5000 --client_uuid '2'
python fedavg_jetson_nano_client.py --server_ip http://127.0.0.1:5000 --client_uuid '3'

Note please change IP and other configuration according to your local environment.

Update FedML Submodule

cd FedML
git checkout master && git pull
cd ..
git add FedML
git commit -m "updating submodule FedML to latest"
git push

fedml-iot's People

Contributors

yh-yao avatar chaoyanghe avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.