### Install and Setup FedML Environment Source: https://github.com/fedml-ai/fedml/blob/master/python/examples/federate/prebuilt_jobs/healthcare/chestxray_clf/README.md Commands to install the FedML library and prepare the local environment by cloning the repository and downloading the ChestXRay dataset. ```bash pip install fedml --upgrade git clone https://github.com/FedML-AI/FedML cd FedML/python/app/healthcare/chestxray_clf/ cd config/ bash bootstrap.sh cd .. cd data/chestxray/ bash download_and_unzip.sh ``` -------------------------------- ### Download Example Datasets Source: https://github.com/fedml-ai/fedml/blob/master/python/spotlight_prj/fedllm/README.md Executes the setup script to download necessary datasets for training and evaluation. ```shell bash scripts/setup.sh ``` -------------------------------- ### Setup YOLOv5 Environment Source: https://github.com/fedml-ai/fedml/blob/master/python/examples/federate/prebuilt_jobs/fedcv/object_detection/model/yolov5/tutorial.ipynb Clones the YOLOv5 repository, installs necessary Python dependencies, and initializes the notebook environment to verify hardware and software compatibility. ```python !git clone https://github.com/ultralytics/yolov5 %cd yolov5 %pip install -qr requirements.txt import torch import utils display = utils.notebook_init() ``` -------------------------------- ### Setup ARM Emulation on x86 Source: https://github.com/fedml-ai/fedml/blob/master/installation/build_fedml_docker/README.md Installs QEMU and related packages to enable emulation of ARM architecture on an x86 system. This is an optional step required for building ARM containers on non-ARM hardware. ```bash sudo apt-get install qemu binfmt-support qemu-user-static ``` -------------------------------- ### Setup FedML Environment Source: https://github.com/fedml-ai/fedml/blob/master/python/examples/federate/prebuilt_jobs/healthcare/fed_heart_disease/README.md Bash commands to clone the repository, install dependencies, and prepare the environment for the Heart Disease application. ```bash git clone https://github.com/FedML-AI/FedML cd FedML/python/app/healthcare/fed_heart_disease pip install -r requirements.txt cd config/ bash bootstrap.sh cd .. pip install flamby[heart_disease] ``` -------------------------------- ### Install FedML from source Source: https://github.com/fedml-ai/fedml/blob/master/installation/README.md Clones the FedML repository, navigates to the python directory, and installs FedML using setup.py. This method is for installing directly from the source code. ```bash git clone https://github.com/FedML-AI/FedML.git && \ cd ./FedML/python && \ python setup.py install ``` -------------------------------- ### Run FedML Server and Client Scripts Source: https://github.com/fedml-ai/fedml/blob/master/python/examples/federate/cross_silo/cuda_rpc_fedavg_mnist_lr_example/README.md These bash commands demonstrate how to launch the FedML server and client processes for the cross-silo example. The server should be started first, followed by clients specifying their respective ranks and a run ID. ```bash run_server.sh your_run_id ``` ```bash run_client.sh 1 your_run_id ``` ```bash run_client.sh 2 your_run_id ``` -------------------------------- ### Run FedML Example (Step-by-Step APIs) Source: https://github.com/fedml-ai/fedml/blob/master/python/examples/federate/simulation/mpi_torch_fedavg_mnist_lr_example/README.md Executes a FedML example using step-by-step APIs. The argument specifies the number of distributed processes. ```bash sh run_step_by_step_example.sh 4 ``` -------------------------------- ### FedML Environment Setup and Requirements Source: https://github.com/fedml-ai/fedml/blob/master/python/examples/federate/prebuilt_jobs/healthcare/fed_isic2019/README.md This section outlines the steps to set up the FedML environment for healthcare applications. It involves cloning the FedML repository, installing dependencies, running a bootstrap script for configuration, and installing the flamby library with healthcare support. ```bash git clone https://github.com/FedML-AI/FedML cd FedML/python/app/healthcare/fed_heart_disease pip install -r requirements.txt cd config/ bash bootstrap.sh cd .. pip install flamby[heart_disease] ``` -------------------------------- ### Install FedNLP Dependencies Source: https://github.com/fedml-ai/fedml/blob/master/python/examples/federate/prebuilt_jobs/fednlp/README.md Commands to set up the environment, install MPI dependencies, and install the FedML framework and project requirements. ```bash cd FedML/python/app/fednlp conda create -n fednlp python=3.8 sudo apt install libopenmpi-dev pip install mpi4py pip install fedml pip install -r requirements.txt ``` -------------------------------- ### Run FedML Example (Custom Dataset and Model) Source: https://github.com/fedml-ai/fedml/blob/master/python/examples/federate/simulation/mpi_torch_fedavg_mnist_lr_example/README.md Executes a FedML example with a custom dataset and model. The argument specifies the number of distributed processes. ```bash sh run_custom_data_and_model_example.sh 4 ``` -------------------------------- ### Run Distributed Example Source: https://github.com/fedml-ai/fedml/blob/master/python/examples/federate/simulation/mpi_torch_fedgkt_mnist_lr_example/README.md Executes a step-by-step distributed training example using a shell script. The script accepts an integer argument representing the number of processes or nodes. ```bash sh run_step_by_step_example.sh 10 ``` -------------------------------- ### Summarization with LLaMA Models Source: https://github.com/fedml-ai/fedml/blob/master/python/examples/deploy/scalellm-multi-engine/src/README.md Examples for running summarization tasks using LLaMA models. This includes configurations for FP16, INT8 quantization, and multi-GPU setups for both LLaMA 7B and 30B models. Dependencies include the `summarize.py` script and pre-built engine directories. ```bash # Run summarization using the LLaMA 7B model in FP16. python summarize.py --test_trt_llm \ --hf_model_location ./tmp/llama/7B/ \ --data_type fp16 \ --engine_dir ./tmp/llama/7B/trt_engines/fp16/1-gpu/ ``` ```bash # Run summarization using the LLaMA 7B model quantized to INT8. python summarize.py --test_trt_llm \ --hf_model_location ./tmp/llama/7B/ \ --data_type fp16 \ --engine_dir ./tmp/llama/7B/trt_engines/weight_only/1-gpu/ ``` ```bash # Run summarization using the LLaMA 7B model in FP16 using two GPUs. mpirun -n 2 --allow-run-as-root \ python summarize.py --test_trt_llm \ --hf_model_location ./tmp/llama/7B/ \ --data_type fp16 \ --engine_dir ./tmp/llama/7B/trt_engines/fp16/2-gpu/ ``` ```bash # Run summarization using the LLaMA 30B model in FP16 using two GPUs. mpirun -n 2 --allow-run-as-root \ python summarize.py --test_trt_llm \ --hf_model_location ./tmp/llama/30B/ \ --data_type fp16 \ --engine_dir ./tmp/llama/30B/trt_engines/fp16/2-gpu/ ``` -------------------------------- ### FedML Launch CLI Example Source: https://github.com/fedml-ai/fedml/blob/master/python/examples/launch/README.md This example demonstrates how to launch a job on the FedML Nexus AI Platform using the `fedml launch` command with a specified YAML configuration file. It shows the typical output during job submission and resource allocation. ```bash fedml launch hello_job.yaml ``` -------------------------------- ### Run FedML Example with Step-by-Step APIs Source: https://github.com/fedml-ai/fedml/blob/master/python/examples/federate/simulation/mpi_fedprox_datasets_and_models_example/README.md Executes a FedML example using a step-by-step API approach. This allows for more granular control over the distributed training process. It requires specifying the number of processes and a configuration file. ```bash sh run_step_by_step_example.sh 4 config/mnist_lr/fedml_config.yaml ``` -------------------------------- ### Run FedML Example (One-Line API) Source: https://github.com/fedml-ai/fedml/blob/master/python/examples/federate/simulation/mpi_torch_fedavg_mnist_lr_example/README.md Executes a FedML example using a one-line API command. The argument specifies the number of distributed processes to run. ```bash sh run_one_line_example.sh 4 ``` -------------------------------- ### Execute FedML Federated Learning Examples Source: https://github.com/fedml-ai/fedml/blob/master/python/examples/federate/simulation/sp_fedavg_mnist_lr_example/README.md Demonstrates how to run various FedML examples using different API patterns. These commands require a configuration file specified by the --cf flag. ```bash python torch_fedavg_mnist_lr_one_line_example.py --cf fedml_config.yaml python torch_fedavg_mnist_lr_step_by_step_example.py --cf fedml_config.yaml python torch_fedavg_mnist_lr_custum_data_and_model_example.py --cf fedml_config.yaml ``` -------------------------------- ### Python Script for Starting Federated Learning Training on Mobile Source: https://github.com/fedml-ai/fedml/blob/master/python/examples/federate/cross_device/mqtt_s3_fedavg_cifar10_resnet20_example/README.md A Python example demonstrating how to configure and send a 'start_train' message to the FedML server. It includes parameters like group ID, learning rate, client IDs, model name, and dataset. This script is used to initiate a federated learning training round on mobile clients. ```python import json # ... (assuming communicator is initialized) def test_start_train_phone_1(self): start_train_json = {"groupid": "38", "clientLearningRate": 0.001, "partitionMethod": "homo", "starttime": 1646068794775, "trainBatchSize": 64, "edgeids": [22, 126], "token": "eyJhbGciOiJIUzI1NiJ9.eyJpZCI6NjAsImFjY291bnQiOiJhbGV4LmxpYW5nIiwibG9naW5UaW1lIjoiMTY0NjA2NTY5MDAwNSIsImV4cCI6MH0.0OTXuMTfxqf2duhkBG1CQDj1UVgconnoSH0PASAEzM4", "modelName": "lenet_mnist", "urls": ["https://fedmls3.s3.amazonaws.com/025c28be-b464-457a-ab17-851ae60767a9"], "clientOptimizer": "adam", "userids": ["60"], "clientNumPerRound": 3, "name": "1646068810", "commRound": 3, "localEpoch": 1, "runId": 189, "id": 169, "projectid": "56", "dataset": "mnist", "communicationBackend": "MQTT_S3", "timestamp": "1646068794778"} self.communicator.send_message("flserver_agent/126/start_train", json.dumps(start_train_json)) ``` -------------------------------- ### Run FedML MNIST PyTorch Example Source: https://github.com/fedml-ai/fedml/blob/master/python/examples/federate/simulation/sp_fednova_mnist_lr_example/README.md Executes a step-by-step federated learning example for MNIST using PyTorch with FedNova. This requires a FedML configuration file. ```bash python torch_fednova_mnist_lr_step_by_step_example.py --cf fedml_config.yaml ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/fedml-ai/fedml/blob/master/python/spotlight_prj/fedllm/README.md Standard command to install required Python packages for the FedLLM environment. ```shell pip install -r requirements.txt ``` -------------------------------- ### Run FedML Example on Localhost Source: https://github.com/fedml-ai/fedml/blob/master/python/examples/federate/simulation/mpi_torch_fedavg_seq/README.md Executes a FedML federated learning example with a specified number of workers and server configuration on the localhost. This is useful for testing and development. ```bash sh run.sh 4 "localhost:5" ``` -------------------------------- ### Example FedML Package Build Commands Source: https://github.com/fedml-ai/fedml/blob/master/python/spotlight_prj/unitedllm/README.md These examples show how to use the `fedml build` command to create packages for the aggregator server and client. They specify the source code location, entry point script, destination directory for the build, and configuration folder. ```shell # build aggregator server package fedml build -t server -sf . -ep launch_fedllm.py -df build -cf "mlops_config" -ig "build" # build client package fedml build -t client -sf . -ep launch_fedllm.py -df build -cf "mlops_config" -ig "build" ``` -------------------------------- ### Run FedML Example with One-Line API Source: https://github.com/fedml-ai/fedml/blob/master/python/examples/federate/simulation/mpi_fedprox_datasets_and_models_example/README.md Executes a FedML example using a single command-line API. This method is convenient for quick testing and demonstrations. It requires specifying the number of processes and a configuration file. ```bash sh run_one_line_example.sh 4 config/mnist_lr/fedml_config.yaml ``` -------------------------------- ### FEDML Train Build Example Command Source: https://github.com/fedml-ai/fedml/blob/master/python/examples/launch/train_build_package/README.md A practical example of how to execute the 'fedml train build' command with a specified YAML file. It also shows the expected output indicating the location of the built package. ```bash fedml train build train_job.yaml Your train package file is located at: /home/fedml/launch/fedml-train-packages/client-package.zip ``` -------------------------------- ### Run FedML Example Script Source: https://github.com/fedml-ai/fedml/blob/master/python/examples/federate/simulation/mpi_decentralized_fl_example/README.md Executes a FedML example using a shell script. The script takes an argument specifying the number of processes to use for the run. ```bash # 4 means 4 processes sh run.sh 4 ``` -------------------------------- ### Execute FedML Distributed Examples Source: https://github.com/fedml-ai/fedml/blob/master/python/examples/federate/simulation/mpi_torch_fedopt_mnist_lr_example/README.md Provides commands to run distributed training examples using different API patterns. The integer argument specifies the number of processes to be initialized for the distributed environment. ```bash # Run using one-line API sh run_one_line_example.sh 4 # Run using step-by-step APIs sh run_step_by_step_example.sh 4 # Run using custom dataset and model sh run_custom_data_and_model_example.sh 4 ``` -------------------------------- ### Run FedML Example with Custom Data and Model Source: https://github.com/fedml-ai/fedml/blob/master/python/examples/federate/simulation/mpi_fedprox_datasets_and_models_example/README.md Executes a FedML example using custom datasets and models. This enables users to integrate their own data and model architectures into the FedML framework. It requires specifying the number of processes and a configuration file. ```bash sh run_custom_data_and_model_example.sh 4 config/mnist_lr/fedml_config.yaml ``` -------------------------------- ### Run FedML Distributed Examples Source: https://github.com/fedml-ai/fedml/blob/master/python/examples/federate/simulation/mpi_torch_fedavg_defense_mnist_lr_example/README.md Executes FedML training examples using different execution modes. The integer argument specifies the number of processes to spawn for the distributed environment. ```bash # Run one-line API example sh run_one_line_example.sh 4 # Run step-by-step API example sh run_step_by_step_example.sh 4 # Run custom dataset and model example sh run_custom_data_and_model_example.sh 4 ``` -------------------------------- ### Run FedML Example on Multiple GPUs Source: https://github.com/fedml-ai/fedml/blob/master/python/examples/federate/simulation/mpi_torch_fedavg_seq/README.md Runs a FedML federated learning example distributed across multiple GPUs on different hosts. This demonstrates how to configure a distributed training environment. ```bash sh run.sh 4 "gpu1:3;gpu2:2" ``` -------------------------------- ### Run FedML MNIST Example Source: https://github.com/fedml-ai/fedml/blob/master/python/examples/federate/simulation/sp_turboaggregate_mnist_lr_example/README.md Executes a PyTorch-based TurboAggregate MNIST example using a specified YAML configuration file. This command assumes the environment is configured and the script is present in the working directory. ```bash python torch_turboaggregate_mnist_lr_step_by_step_example.py --cf fedml_config.yaml ``` -------------------------------- ### Shell: Clone FedML Example Repository Source: https://github.com/fedml-ai/fedml/blob/master/python/fedml/workflow/driver_example/customized_job_example/README.md This command clones the FedML GitHub repository, specifically checking out a development branch. It then navigates into a directory containing customized job examples, allowing you to explore and run FedML workflows locally. ```shell git clone -b alexleung/dev_branch_latest_sync https://github.com/FedML-AI/FedML cd python/fedml/workflow/driver_example/customized_job_example ``` -------------------------------- ### Run FedML Edge Server and Client using MQTT Source: https://github.com/fedml-ai/fedml/blob/master/python/examples/federate/prebuilt_jobs/healthcare/fed_isic2019/README.md These commands demonstrate how to run the FedML edge server and clients using the MQTT protocol. The server is started with a run ID, and clients are started in separate terminals, each identified by a client ID and the same run ID. ```bash bash run_server.sh your_run_id # in a new terminal window bash run_client.sh [CLIENT_ID] your_run_id ``` -------------------------------- ### FedML Initialization and Basic Setup Source: https://context7.com/fedml-ai/fedml/llms.txt Initializes FedML, retrieves the device, loads the dataset, creates the model, and sets up the trainer, aggregator, and runner for a federated learning process. ```python args = fedml.init() device = fedml.device.get_device(args) dataset, output_dim = fedml.data.load(args) model = fedml.model.create(args, output_dim) trainer = MyTrainer(model, args) aggregator = MyAggregator(model, args) runner = FedMLRunner(args, device, dataset, model, client_trainer=trainer, server_aggregator=aggregator) runner.run() ``` -------------------------------- ### Install FedML with pip on CentOS Source: https://github.com/fedml-ai/fedml/blob/master/installation/README.md Installs pip3 and FedML on CentOS systems. It also sets the PATH environment variable and runs the fedml env command for environment setup. ```bash yum –y install python3-pip pip3 install fedml export PATH=$HOME/.local/bin:$PATH fedml env ``` -------------------------------- ### Install FedML with pip on Ubuntu Source: https://github.com/fedml-ai/fedml/blob/master/installation/README.md Installs pip3 and FedML on Ubuntu systems. It also sets the PATH environment variable and runs the fedml env command for environment setup. ```bash sudo apt-get update && sudo apt install python3-pip pip3 install fedml export PATH=$HOME/.local/bin:$PATH fedml env ``` -------------------------------- ### Install FedML from source with optional ML engine dependencies Source: https://github.com/fedml-ai/fedml/blob/master/installation/README.md Installs FedML from source with optional dependencies for TensorFlow, Jax, or MXNet. This allows running examples that utilize these specific ML engines. ```bash git clone https://github.com/FedML-AI/FedML.git && \ cd ./FedML/python && \ python install -e '.[tensorflow]' python install -e '.[jax]' python install -e '.[mxnet]' ``` -------------------------------- ### FedML Client Initialization and Run (Python) Source: https://github.com/fedml-ai/fedml/blob/master/python/examples/federate/cross_silo/mqtt_s3_fedavg_horizontal_mnist_lr_example/README.md This Python snippet demonstrates the basic initialization of the FedML framework, device selection, data loading, model creation, and starting the client's training run. It's a concise entry point for understanding the core FedML client workflow. ```python import fedml from fedml.cross_silo.hierarchical import Client if __name__ == "__main__": # init FedML framework args = fedml.init() device = fedml.device.get_device(args) # load data dataset, output_dim = fedml.data.load(args) # load model model = fedml.model.create(args, output_dim) # start training client = Client(args, device, dataset, model) client.run() ``` -------------------------------- ### FedML Camelyon16 Environment Setup (Bash) Source: https://github.com/fedml-ai/fedml/blob/master/python/examples/federate/prebuilt_jobs/healthcare/fed_camelyon16/README.md Bash script to set up the FedML environment for Camelyon16. It involves cloning the FedML repository, installing dependencies, running a bootstrap script for configuration, and installing the flamby library with Camelyon16 support. ```bash git clone https://github.com/FedML-AI/FedML cd FedML/python/app/healthcare/fed_camelyon16 pip install -r requirements.txt cd config/ bash bootstrap.sh cd .. pip install flamby[camelyon16] ``` -------------------------------- ### FedML Healthcare Environment Setup Source: https://github.com/fedml-ai/fedml/blob/master/python/examples/federate/prebuilt_jobs/healthcare/fed_tcga_brca/README.md This sequence of commands sets up the FedML environment for the TCGA-BRCA healthcare application. It involves cloning the repository, installing dependencies, and configuring the project. ```bash git clone https://github.com/FedML-AI/FedML cd FedML/python/app/healthcare/fed_tcga_brca pip install -r requirements.txt cd config/ bash bootstrap.sh cd .. pip install flamby[tcga_brca] ``` -------------------------------- ### Prepare Android Environment Source: https://github.com/fedml-ai/fedml/blob/master/python/examples/federate/cross_device/mqtt_s3_fedavg_mnist_lenet_example/README.md Installs necessary Android platform tools and executes the preparation script for device communication. ```bash brew install android-platform-tools ../prepare.sh ``` -------------------------------- ### Install FedML using Anaconda Source: https://github.com/fedml-ai/fedml/blob/master/installation/README.md Sets up a dedicated conda environment with Python 3.8, installs pip, and then installs FedML using pip. It also provides troubleshooting steps for MacOS with Python 3.11. ```bash conda create --name fedml-pip python=3.8 conda activate fedml-pip conda install --name fedml-pip pip pip install fedml ``` -------------------------------- ### Install FedML from TestPyPI Source: https://github.com/fedml-ai/fedml/blob/master/python/RELEASE.md Installs the FedML package from the Python Package Index (PyPI) test server. This command is used to install a version of FedML that has been uploaded to the test PyPI for preliminary testing before a full release. ```bash pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple fedml ``` -------------------------------- ### Run MQTT Server and Client Source: https://github.com/fedml-ai/fedml/blob/master/python/examples/federate/prebuilt_jobs/healthcare/fed_heart_disease/README.md Commands to start the edge server and individual clients using the MQTT protocol. ```bash bash run_server.sh your_run_id bash run_client.sh [CLIENT_ID] your_run_id ``` -------------------------------- ### Local FedML Installation with Extras Source: https://github.com/fedml-ai/fedml/blob/master/python/RELEASE.md Installs FedML with optional dependencies for specific machine learning frameworks and communication backends. This allows users to tailor the installation to their needs, such as enabling TensorFlow, JAX, MXNet, MPI, or gRPC support. ```bash # TensorFlow extra installation pip install -e '.[tensorflow]' # JAX extra installation pip install -e '.[jax]' # MXNet extra installation pip install -e '.[mxnet]' # for different communication backends pip install -e '.[MPI]' pip install -e '.[gRPC]' ``` -------------------------------- ### Shell: Install FedML Library Source: https://github.com/fedml-ai/fedml/blob/master/python/fedml/workflow/driver_example/customized_job_example/README.md This command installs a specific version of the FedML library using pip. It specifies the index URLs to use for package retrieval, ensuring the correct version is installed in your local Python environment or GPU server. ```shell pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple fedml==0.8.58 ``` -------------------------------- ### FedML Python API - Device Management Source: https://context7.com/fedml-ai/fedml/llms.txt Demonstrates how to use `fedml.device.get_device()` to initialize the training device (GPU or CPU) based on configuration and availability. ```APIDOC ## FedML Python API - Device Management ### Description The `fedml.device.get_device()` function handles device initialization for training, automatically selecting GPU or CPU based on configuration and availability. ### Usage ```python import fedml args = fedml.init() # Get the appropriate device (GPU or CPU) device = fedml.device.get_device(args) print(f"Using device: {device}") # Get device type string device_type = fedml.device.get_device_type(args) print(f"Device type: {device_type}") # "gpu" or "cpu" # Configuration in fedml_config.yaml: # device_args: # using_gpu: true # gpu_mapping_file: config/gpu_mapping.yaml # gpu_mapping_key: mapping_default # # For MPI-based training, gpu_mapping.yaml specifies GPU assignment: # mapping_default: # host1: [0, 1] # GPUs 0 and 1 on host1 ``` ``` -------------------------------- ### Install FedGraphNN Dependencies Source: https://github.com/fedml-ai/fedml/blob/master/python/examples/federate/prebuilt_jobs/fedgraphnn/README.md Commands to install the core FedML library and the PyTorch Geometric library required for running FedGraphNN experiments. ```shell pip install fedml conda install pyg -c pyg ``` -------------------------------- ### Install YOLOv5 Repository Source: https://github.com/fedml-ai/fedml/blob/master/python/examples/federate/prebuilt_jobs/fedcv/object_detection/model/yolov5/README.md Clones the YOLOv5 repository from GitHub and installs the required Python dependencies. Requires Python 3.7+ and PyTorch 1.7+. ```bash git clone https://github.com/ultralytics/yolov5 cd yolov5 pip install -r requirements.txt ``` -------------------------------- ### Install FedML Package Source: https://github.com/fedml-ai/fedml/blob/master/python/examples/federate/prebuilt_jobs/fedcv/README.md Installs the FedML package, which is the core library for FedCV. This is a prerequisite for using the framework and its functionalities. It should be run using pip. ```bash pip install fedml --upgrade ``` -------------------------------- ### Install FedML Dependencies Source: https://github.com/fedml-ai/fedml/blob/master/python/build_tools/lint/README.md Installs the required FedML packages for various framework backends including MPI, gRPC, TensorFlow, JAX, and MXNet. ```bash pip install "fedml[MPI]" pip install "fedml[gRPC]" pip install "fedml[tensorflow]" pip install "fedml[jax]" pip install "fedml[mxnet]" ``` -------------------------------- ### Run Server and Client using MQTT Source: https://github.com/fedml-ai/fedml/blob/master/python/examples/federate/prebuilt_jobs/fedcv/README.md Starts the federated learning server and clients using the MQTT protocol. This enables communication between the central server and distributed clients for training. Client IDs and run IDs can be specified. ```bash bash run_server.sh your_run_id # in a new terminal window # run the client 1 bash run_client.sh 1 your_run_id # run the client with client_id bash run_client.sh [CLIENT_ID] your_run_id ``` -------------------------------- ### Initialize and Run FedML Client Source: https://github.com/fedml-ai/fedml/blob/master/python/examples/federate/cross_silo/mqtt_s3_fedavg_hierarchical_manual_mnist_lr_example/README.md The main entry point to initialize the FedML framework, load data, instantiate the model, and start the hierarchical client training process. ```python if __name__ == "__main__": args = fedml.init() device = fedml.device.get_device(args) dataset, output_dim = load_data(args) model = LogisticRegression(28 * 28, output_dim) client = Client(args, device, dataset, model) client.run() ``` -------------------------------- ### Install Dependencies for MNN and ONNX Source: https://github.com/fedml-ai/fedml/blob/master/android/fedmlsdk/MobileNN/test/README.md Installs necessary Python packages and clones the MNN library, which is a prerequisite for C++ compilation and model conversion. ```bash pip install onnx pip install mnn # The MNN lib is required for cpp comilation cd android/fedmlsdk/MobileNN git clone https://github.com/FedML-AI/MNN ``` -------------------------------- ### Load YOLOv7-w6 Model Configuration (Python) Source: https://github.com/fedml-ai/fedml/blob/master/python/examples/federate/prebuilt_jobs/fedcv/object_detection/model/yolov7/tools/reparameterization.ipynb This snippet demonstrates loading the configuration for a YOLOv7-w6 model. It initializes the device and loads the model's checkpoint file, preparing it for further processing or deployment. This is a foundational step for using this specific YOLO variant. ```python # import from copy import deepcopy from models.yolo import Model import torch from utils.torch_utils import select_device, is_parallel device = select_device('0', batch_size=1) # model trained by cfg/training/*.yaml ckpt = torch.load('cfg/training/yolov7-w6.pt', map_location=device) # reparameterized model in cfg/deploy/*.yaml model = Model('cfg/deploy/yolov7-w6.yaml', ch=3, nc=80).to(device) ``` -------------------------------- ### Install OpenVINO Development Dependencies Source: https://github.com/fedml-ai/fedml/blob/master/python/examples/federate/prebuilt_jobs/fedcv/object_detection/model/yolov6/deploy/OpenVINO/README.md Installs the required Python packages for OpenVINO model conversion. This ensures the environment has the latest pip and the openvino-dev toolkit. ```shell pip install --upgrade pip pip install openvino-dev ``` -------------------------------- ### Install mpi4py and openmpi on MacOS (conda) Source: https://github.com/fedml-ai/fedml/blob/master/installation/README.md Installs mpi4py and openmpi within a conda environment on MacOS, required for MPI-based local distributed simulation. ```bash conda install mpi4py openmpi ``` -------------------------------- ### Bind Device and Deploy Model On-Premise with FedML CLI Source: https://github.com/fedml-ai/fedml/blob/master/python/examples/deploy/scalellm-multi-engine/README.md This section details deploying a model on an on-premise environment. It involves binding a device using an API key and then deploying the model specifying master and worker IDs. ```bash fedml device bind $api_key ``` ```bash fedml model deploy -n my_model -m $master_ids -w $worker_ids ```