There are a few ways to set up your environment to use TensorFlow Federated (TFF):
- The easiest way to learn and use TFF requires no installation—run the TensorFlow Federated tutorials directly in your browser using Google Colaboratory.
- To use TensorFlow Federated on a local machine, install the
TFF package with Python's
pip
package manager. - If you have a unique machine configuration, build TensorFlow Federated from source.
On Ubuntu:
sudo apt update
sudo apt install python3-dev python3-pip # Python 3
sudo pip3 install --upgrade virtualenv # system-wide install
On macOS:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
export PATH="/usr/local/bin:/usr/local/sbin:$PATH"
brew update
brew install python # Python 3
sudo pip3 install --upgrade virtualenv # system-wide install
virtualenv --python python3 "venv"
source "venv/bin/activate"
pip install --upgrade pip
Note: To exit the virtual environment, run deactivate
.
pip install --upgrade tensorflow_federated
python -c "import tensorflow_federated as tff; print(tff.federated_computation(lambda: 'Hello World')())"
Success: TensorFlow Federated is now installed.
On Ubuntu:
sudo apt update
sudo apt install python3-dev python3-pip # Python 3
sudo pip3 install --upgrade virtualenv # system-wide install
On macOS:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
export PATH="/usr/local/bin:/usr/local/sbin:$PATH"
brew update
brew install python # Python 3
sudo pip3 install --upgrade virtualenv # system-wide install
Install Bazel, the build tool used to compile Tensorflow Federated.
git clone https://github.com/tensorflow/federated.git
cd "federated"
virtualenv --python python3 "venv"
source "venv/bin/activate"
pip install --upgrade pip
Note: To exit the virtual environment, run deactivate
.
pip install --requirement "requirements.txt"
bazel test //tensorflow_federated/...
mkdir "/tmp/tensorflow_federated"
bazel run //tensorflow_federated/tools/development:build_pip_package -- \ "/tmp/tensorflow_federated"
mkdir "/tmp/project"
cd "/tmp/project"
virtualenv --python python3 "venv"
source "venv/bin/activate"
pip install --upgrade pip
Note: To exit the virtual environment run deactivate
.
pip install --upgrade "/tmp/tensorflow_federated/tensorflow_federated-"*".whl"
python -c "import tensorflow_federated as tff; print(tff.federated_computation(lambda: 'Hello World')())"
Success: The TensorFlow Federated package is built.
Create a Tensorflow Federated development environment using Docker on Ubuntu or macOS.
Install Docker on your local machine.
git clone https://github.com/tensorflow/federated.git
cd "federated"
docker build . \
--tag tensorflow_federated
docker run \
--interactive \
--tty \
--volume $(pwd):/federated \
--workdir /federated \
tensorflow_federated \
bash
bazel test //tensorflow_federated/...
Success: The TensorFlow Federated development environment is ready, now build the pip package.