"Cyclic Weight Transfer" (CWT) is an alternative to FedAvg. CWT uses the Cyclic Controller to pass the model weights from one site to the next for repeated fine-tuning.
NOTE: This example uses the MNIST handwritten digits dataset and will load its data within the trainer code.
To run this example with the FLARE API, you can follow the hello_world notebook, or you can quickly get started with the following:
Follow the Installation instructions to install NVFlare.
Install additional requirements (if you already have a specific version of nvflare installed in your environment, you may want to remove nvflare in the requirements to avoid reinstalling nvflare):
pip3 install tensorflow
Prepare the data first:
bash ./prepare_data.sh
Run the script using the job API to create the job and run it with the simulator:
python3 cyclic_script_runner.py
You can find the running logs and results inside the simulator's workspace:
$ ls /tmp/nvflare/jobs/workdir
For running with GPUs, we recommend using the NVIDIA TensorFlow docker
If you choose to run the example using GPUs, it is important to note that by default, TensorFlow will attempt to allocate all available GPU memory at the start. In scenarios where multiple clients are involved, you have a couple of options to address this.
One approach is to include specific flags to prevent TensorFlow from allocating all GPU memory. For instance:
TF_FORCE_GPU_ALLOW_GROWTH=true python3 cyclic_script-executor-hello-cyclic.py