Installation

This guide covers the installation of NVIDIA FLARE and its dependencies. Before proceeding, make sure you understand the basics of federated learning from the What is Federated Learning? and have reviewed the NVIDIA FLARE Overview to understand what you’ll be installing.

Prerequisites

  • Python 3.9+

  • pip

  • Git

Note

The server and client versions of nvflare must match, we do not support cross-version compatibility.

Supported Operating Systems

  • Linux

  • OSX (Note: some optional dependencies are not compatible, such as tenseal and openmined.psi)

Installation Methods

Virtual Environment Setup

It is highly recommended to install NVIDIA FLARE in a virtual environment if you are not using Containerized Deployment. This guide briefly describes how to create a virtual environment with venv.

Virtual Environments and Packages

Python’s official document explains the main idea about virtual environments. The module used to create and manage virtual environments is called venv. You can find more information there. We only describe a few necessary steps for a virtual environment for NVIDIA FLARE.

Depending on your OS and the Python distribution, you may need to install the Python’s venv package separately. For example, in Ubuntu 20.04, you need to run the following commands to continue creating a virtual environment with venv.

$ sudo apt update
$ sudo apt-get install python3-venv

Once venv is installed, you can use it to create a virtual environment with:

$ python3 -m venv nvflare-env

This will create the nvflare-env directory in current working directory if it doesn’t exist, and also create directories inside it containing a copy of the Python interpreter, the standard library, and various supporting files.

Activate the virtualenv by running the following command:

$ source nvflare-env/bin/activate

You may find that the pip and setuptools versions in the venv need updating:

(nvflare-env) $ python3 -m pip install -U pip
(nvflare-env) $ python3 -m pip install -U setuptools

Install Stable Release

Stable releases are available on NVIDIA FLARE PyPI:

$ python3 -m pip install nvflare

Optional Dependencies

NVFlare provides several optional dependency groups that you can install based on your needs:

  • HE - Homomorphic Encryption support:

    $ pip install nvflare[HE]
    
  • PSI - Private Set Intersection support:

    $ pip install nvflare[PSI]
    
  • PT - PyTorch support:

    $ pip install nvflare[PT]
    
  • SKLEARN - Scikit-learn support:

    $ pip install nvflare[SKLEARN]
    
  • TRACKING - MLflow, Weights & Biases, and TensorBoard support:

    $ pip install nvflare[TRACKING]
    
  • MONITORING - Datadog monitoring support:

    $ pip install nvflare[MONITORING]
    
  • CONFIG - OmegaConf configuration support:

    $ pip install nvflare[CONFIG]
    

You can also install multiple optional dependencies at once:

$ pip install nvflare[PT,SKLEARN,TRACKING]  # Install PyTorch, Scikit-learn, and tracking support

For development, you can install all dependencies (except HE and PSI on macOS):

# On Linux
$ pip install nvflare[dev]

# On macOS
$ pip install nvflare[dev_mac]

Install from Source

Clone NVFlare repo and install from source (useful for accessing latest nightly features or testing custom builds):

$ git clone https://github.com/NVIDIA/NVFlare.git
$ cd NVFlare
$ pip install -e .  # Install in editable mode

You can also install with optional dependencies from source:

$ pip install -e ".[dev]"  # Install all development dependencies
$ pip install -e ".[PT,SKLEARN]"  # Install specific optional dependencies

Note on branches:

  • The main branch is the default (unstable) development branch

  • The 2.1, 2.2, 2.3, 2.4, 2.5, etc. branches are the branches for each major release and there are tags based on these with a third digit for minor patches

To switch to a specific branch:

$ git switch 2.6  # Replace with desired version

Building Wheels

You can build wheel packages for NVFlare using the following steps:

  1. Install build dependencies:

$ pip install build wheel
  1. Build the wheel:

$ python -m build

This will create wheel files in the dist/ directory. The wheel files can be installed using pip:

$ pip install dist/nvflare-*.whl

Note

Building wheels requires all build dependencies to be installed. If you encounter any issues, make sure you have the latest version of pip, setuptools, and wheel installed.

Building for Specific Platforms

To build wheels for specific platforms or Python versions, you can use the following environment variables:

# For a specific Python version
$ PYTHON=python3.9 python -m build

# For a specific platform
$ PLATFORM=linux_x86_64 python -m build

Note

The platform-specific builds are useful when you need to distribute wheels to systems with different architectures or Python versions.

Next Steps

After completing the installation:

  1. Follow the Quickstart guide to run your first federated learning example

  2. Learn more about different ways to use NVFlare in the Getting Started guide

  3. Explore more examples in the Example Applications section

  4. When ready for production, see Real-World Federated Learning for deployment guidance