Skip to content

GTA-UFRJ/SunFlower

Repository files navigation

SunFlower

Secure in Unreliable Network Federated Learning

Dependencies

  • Python 3.8
  • Gramine-SGX
  • PyTorch
  • Torchvision
  • Flask
  • PyCryptodomex
  • NumPy
  • SciPy
  • MatplotLib
  • Requests

Running a bare-metal example

Generating data

Edit data/config.ini file. Example for running two IID clients for MNIST:

[dataset]
dataset = mnist 
num_partitions = 2
num_used_clients = 2
train_batch_size = 32
server_test_batch_size = 32
train_fraction = 0.9
data_path = data_generation
download = true

[exec_mode]
exec_mode = baremetal

Generate datasets:

cd data
python gen_dir_tree.py # Just for first execution
python generate_iid_datasets.py

A report will be presented in data/MNIST/info file

Running server

Go to the repository root.

First, run the SunFlower server communication daemon:

python -m core.server.exchange_model_server --max_rounds 10 --server_ip 0.0.0.0 --server_port 7777

Then, in another terminal, run the FL server for this example:

python -m example.server

Running clients

First, run the SunFlower client communication daemon:

python -m core.client.exchange_model_client --id 0 --server_ip 0.0.0.0 --server_port 7777

Then, in another terminal, run the FL client for this example:

python -m example.client 0

Repeat the same commands, but replacing argument 0 by 1.

Running an example with Gramine-Direct

Generating data

Change the following lines in data/config.ini file:

...
download = false

[exec_mode]
exec_mode = gramine

Prepare Gramine manifest:

make -f generate_iid_datasets.makefile

Run inside Gramine

gramine-direct generate_iid_datasets generate_iid_datasets.py 

Generating server

Go to the repository root.

Prepare manifest for server:

make -f example/server.makefile DATA_PATH=$(pwd)/data/MNIST

Running server

Before running a new execution, clean previous files:

bash clean_exec.sh

First, run the SunFlower server communication daemon, which does not depend on Gramine:

python -m core.server.exchange_model_server --max_rounds 10 --server_ip 0.0.0.0 --server_port 7777

Then, in another terminal, run the FL server for this example:

gramine-direct example/server -m example.server 

Generating client

Prepare manifest for client:

make -f example/client.makefile DATA_PATH=$(pwd)/data/MNIST

Running clients

First, run the SunFlower client communication daemon:

python -m core.client.exchange_model_client --id 0 --server_ip 0.0.0.0 --server_port 7777

Then, in another terminal, run the FL client for this example:

gramine-direct example/client -m example.client 0 & echo $! > core/client/_pids/_pid_0

Repeat the same commands, but replacing argument 0 by 1.

Running an example with Gramine-SGX

The data generated is exactly the same one generated for Gramine-Direct

Generating server

Go to the repository root.

Prepare manifest for server:

make -f example/server.makefile DATA_PATH=$(pwd)/data/MNIST SGX=1

Running server

Before running a new execution, clean previous files:

bash clean_exec.sh

First, run the SunFlower server communication daemon, which does not depend on Gramine:

python -m core.server.exchange_model_server --max_rounds 10 --server_ip 0.0.0.0 --server_port 7777 --logfile logs/server_comm

Then, in another terminal, run the FL server for this example:

gramine-sgx example/server -m example.server 

Generating client

Prepare manifest for client:

make -f example/client.makefile DATA_PATH=$(pwd)/data/MNIST SGX=1

Running clients

First, run the SunFlower client communication daemon:

python -m core.client.exchange_model_client --id 0 --server_ip 0.0.0.0 --server_port 7777 --logfile logs/client_comm

Then, in another terminal, run the FL client for this example:

gramine-sgx example/client -m example.client 0 & echo $! > core/client/_pids/_pid_0

Repeat the same commands, but replacing argument 0 by 1.

Experiment

bash run_gramine_direct.sh >> logs/main 2>&1

Running with UBOTA/FUB for communication

Replace core.server.exchange_model_server and core.server.exchange_model_client by:

python -m core.client.ubota_client --id 0 --server_ip 0.0.0.0 --server_port 7777
python -m core.server.ubota_server --max_rounds 10 --server_ip 0.0.0.0 --server_port 7777

About

Secure in Unreliable Network Federated Learning

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors