Installation

  1. You can install PFLlib via git:

  2. git clone https://github.com/TsingZ0/PFLlib.git
  3. Then install CUDA v11.6 following NVIDIA's instructions.

  4. Install the latest version of conda and activate conda.

  5. Install the required Python dependencies using env_cuda_latest.yaml and conda:

  6. conda env create -f env_cuda_latest.yaml # You may need to downgrade the torch using pip to match the CUDA version.

Usage

Only two command lines are needed: one for dataset assignment and the other for FL algorithm execution.

  1. First, split the dataset (e.g., MNIST) and assign it to the clients:
  2. # In ./dataset
    python generate_MNIST.py noniid - dir # for practical noniid and unbalanced scenario
  3. Finally, run the main.py with choosen configurations, FL algorithm, and hyperparameters:
  4. # In ./system
    python main.py -data MNIST -m CNN -algo FedAvg -gr 2000 -did 0 # using the MNIST dataset, the FedAvg algorithm, and the 4-layer CNN model
Note It is preferable to tune algorithm-specific hyper-parameters before using any algorithm on a new machine.