Secure in Unreliable Network Federated Learning
- Python 3.8
- Gramine-SGX
- PyTorch
- Torchvision
- Flask
- PyCryptodomex
- NumPy
- SciPy
- MatplotLib
- Requests
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 = baremetalGenerate datasets:
cd data
python gen_dir_tree.py # Just for first execution
python generate_iid_datasets.pyA report will be presented in data/MNIST/info file
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 7777Then, in another terminal, run the FL server for this example:
python -m example.serverFirst, run the SunFlower client communication daemon:
python -m core.client.exchange_model_client --id 0 --server_ip 0.0.0.0 --server_port 7777Then, in another terminal, run the FL client for this example:
python -m example.client 0Repeat the same commands, but replacing argument 0 by 1.
Change the following lines in data/config.ini file:
...
download = false
[exec_mode]
exec_mode = graminePrepare Gramine manifest:
make -f generate_iid_datasets.makefileRun inside Gramine
gramine-direct generate_iid_datasets generate_iid_datasets.py Go to the repository root.
Prepare manifest for server:
make -f example/server.makefile DATA_PATH=$(pwd)/data/MNISTBefore running a new execution, clean previous files:
bash clean_exec.shFirst, 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 7777Then, in another terminal, run the FL server for this example:
gramine-direct example/server -m example.server Prepare manifest for client:
make -f example/client.makefile DATA_PATH=$(pwd)/data/MNISTFirst, run the SunFlower client communication daemon:
python -m core.client.exchange_model_client --id 0 --server_ip 0.0.0.0 --server_port 7777Then, in another terminal, run the FL client for this example:
gramine-direct example/client -m example.client 0 & echo $! > core/client/_pids/_pid_0Repeat the same commands, but replacing argument 0 by 1.
The data generated is exactly the same one generated for Gramine-Direct
Go to the repository root.
Prepare manifest for server:
make -f example/server.makefile DATA_PATH=$(pwd)/data/MNIST SGX=1Before running a new execution, clean previous files:
bash clean_exec.shFirst, 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_commThen, in another terminal, run the FL server for this example:
gramine-sgx example/server -m example.server Prepare manifest for client:
make -f example/client.makefile DATA_PATH=$(pwd)/data/MNIST SGX=1First, 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_commThen, in another terminal, run the FL client for this example:
gramine-sgx example/client -m example.client 0 & echo $! > core/client/_pids/_pid_0Repeat the same commands, but replacing argument 0 by 1.
bash run_gramine_direct.sh >> logs/main 2>&1Replace 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 7777python -m core.server.ubota_server --max_rounds 10 --server_ip 0.0.0.0 --server_port 7777