Skip to content

Commit

Permalink
Update simulation step-by-step example (#2726)
Browse files Browse the repository at this point in the history
  • Loading branch information
jafermarq authored Jan 30, 2024
1 parent b9b0a90 commit 354cfa1
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def client_fn(cid: str):
trainloader=trainloaders[int(cid)],
vallodaer=valloaders[int(cid)],
num_classes=num_classes,
)
).to_client()

# return the function to spawn client
return client_fn
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,6 @@ def client_fn(cid: str):
trainloader=trainloaders[int(cid)],
vallodaer=valloaders[int(cid)],
model_cfg=model_cfg,
)
).to_client()

return client_fn
13 changes: 6 additions & 7 deletions examples/flower-simulation-step-by-step-pytorch/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Flower Simulation Step-by-Step

> Since this tutorial (and its video series) was put together, Flower has been updated a few times. As a result, some of the steps to construct the environment (see below) have been updated. Some parts of the code have also been updated. Overall, the content of this tutorial and how things work remains the same as in the video tutorials.
This directory contains the code developed in the `Flower Simulation` tutorial series on Youtube. You can find all the videos [here](https://www.youtube.com/playlist?list=PLNG4feLHqCWlnj8a_E1A_n5zr2-8pafTB) or clicking on the video preview below.

- In `Part-I` (7 videos) we developed from scratch a complete Federated Learning pipeline for simulation using PyTorch.
Expand All @@ -19,20 +21,17 @@ As presented in the video, we first need to create a Python environment. You are
# I'm assuming you are running this on an Ubuntu 22.04 machine (GPU is not required)

# create the environment
conda create -n flower_tutorial python=3.8 -y
conda create -n flower_tutorial python=3.9 -y

# activate your environment (depending on how you installed conda you might need to use `conda activate ...` instead)
source activate flower_tutorial

# install PyToch (other versions would likely work)
conda install pytorch==1.13.1 torchvision==0.14.1 torchaudio==0.13.1 pytorch-cuda=11.6 -c pytorch -c nvidia -y
# conda install pytorch==1.13.1 torchvision==0.14.1 torchaudio==0.13.1 -c pytorch # If you don't have a GPU
# conda install pytorch==1.13.1 torchvision==0.14.1 torchaudio==0.13.1 -c pytorch -y # If you don't have a GPU

# install flower (for FL) and hydra (for configs)
pip install flwr==1.4.0 hydra-core==1.3.2
# install ray
# you might see some warning messages after installing it (you can ignore them)
pip install ray==1.11.1
# Install Flower and other dependencies
pip install -r requirements.txt
```

If you are running this on macOS with Apple Silicon (i.e. M1, M2), you'll need a different `grpcio` package if you see an error when running the code. To fix this do:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
flwr[simulation]>=1.0, <2.0
hydra-core==1.3.2

0 comments on commit 354cfa1

Please sign in to comment.