Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update NVFlare demo to work with the latest release #8576

Merged
merged 1 commit into from
Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions demo/nvflare/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ This directory contains a demo of Federated Learning using
To run the demo, first build XGBoost with the federated learning plugin enabled (see the
[README](../../plugin/federated/README.md)).

Install NVFlare (note that currently NVFlare only supports Python 3.8; for NVFlare 2.1.2 we also
need to pin the protobuf package to 3.20.x to avoid protoc errors):
Install NVFlare (note that currently NVFlare only supports Python 3.8):
```shell
pip install nvflare protobuf==3.20.1
pip install nvflare
```

Prepare the data:
Expand All @@ -21,22 +20,22 @@ Prepare the data:

Start the NVFlare federated server:
```shell
./poc/server/startup/start.sh
/tmp/nvflare/poc/server/startup/start.sh
```

In another terminal, start the first worker:
```shell
./poc/site-1/startup/start.sh
/tmp/nvflare/poc/site-1/startup/start.sh
```

And the second worker:
```shell
./poc/site-2/startup/start.sh
/tmp/nvflare/poc/site-2/startup/start.sh
```

Then start the admin CLI, using `admin/admin` as username/password:
Then start the admin CLI:
```shell
./poc/admin/startup/fl_admin.sh
/tmp/nvflare/poc/admin/startup/fl_admin.sh
```

In the admin CLI, run the following command:
Expand All @@ -45,10 +44,10 @@ submit_job hello-xgboost
```

Once the training finishes, the model file should be written into
`./poc/site-1/run_1/test.model.json` and `./poc/site-2/run_1/test.model.json`
`/tmp/nvlfare/poc/site-1/run_1/test.model.json` and `/tmp/nvflare/poc/site-2/run_1/test.model.json`
respectively.

Finally, shutdown everything from the admin CLI:
Finally, shutdown everything from the admin CLI, using `admin` as password:
```shell
shutdown client
shutdown server
Expand Down
14 changes: 7 additions & 7 deletions demo/nvflare/prepare_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ openssl req -x509 -newkey rsa:2048 -days 7 -nodes -keyout client-key.pem -out cl
split -n l/${world_size} --numeric-suffixes=1 -a 1 ../data/agaricus.txt.train agaricus.txt.train-site-
split -n l/${world_size} --numeric-suffixes=1 -a 1 ../data/agaricus.txt.test agaricus.txt.test-site-

poc -n 2
mkdir -p poc/admin/transfer/hello-xgboost
cp -fr config custom poc/admin/transfer/hello-xgboost
cp server-*.pem client-cert.pem poc/server/
nvflare poc -n 2 --prepare
mkdir -p /tmp/nvflare/poc/admin/transfer/hello-xgboost
cp -fr config custom /tmp/nvflare/poc/admin/transfer/hello-xgboost
cp server-*.pem client-cert.pem /tmp/nvflare/poc/server/
for id in $(eval echo "{1..$world_size}"); do
cp server-cert.pem client-*.pem poc/site-"$id"/
cp agaricus.txt.train-site-"$id" poc/site-"$id"/agaricus.txt.train
cp agaricus.txt.test-site-"$id" poc/site-"$id"/agaricus.txt.test
cp server-cert.pem client-*.pem /tmp/nvflare/poc/site-"$id"/
cp agaricus.txt.train-site-"$id" /tmp/nvflare/poc/site-"$id"/agaricus.txt.train
cp agaricus.txt.test-site-"$id" /tmp/nvflare/poc/site-"$id"/agaricus.txt.test
done