Michael24
Michael24

Reputation: 59

How to install Tensorflow federated directly from GitHub or local download?

I want to have access to features from TensorFlow federated (tff.python.research) which aren't present with the pip3 install method.

I'm working on a remote server that does not have bazel, thus I cannot build from source. Are there other ways to get and install the latest working version of TFF from its GitHub REPO?

(https://github.com/tensorflow/federated)

Upvotes: 1

Views: 3070

Answers (1)

TF_Support
TF_Support

Reputation: 1836

To install the latest Tensorflow 2.0 federated, you may follow the steps below.

Install TensorFlow Federated using pip

  1. Install the Python development environment
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
  1. Create a virtual environment
$ virtualenv --python python3 "venv"
$ source "venv/bin/activate"
(venv) $ pip install --upgrade pip


Note: To exit the virtual environment, run deactivate.
  1. Install the TensorFlow Federated pip package.
(venv) $ pip install --upgrade tensorflow_federated
  1. (Optional) Test Tensorflow Federated.
(venv) $ python -c "import tensorflow_federated as tff; print(tff.federated_computation(lambda: 'Hello World')())"

Build the TensorFlow Federated pip package

  1. Install the Python development environment.
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
  1. Install Bazel Install Bazel, the build tool used to compile Tensorflow Federated.

  2. Clone the Tensorflow Federated repository.

$ git clone https://github.com/tensorflow/federated.git
$ cd "federated"
  1. Create a virtual environment.
$ virtualenv --python python3 "venv"
$ source "venv/bin/activate"
(venv) $ pip install --upgrade pip

Note: To exit the virtual environment, run deactivate.
  1. Install Tensorflow Federated dependencies.
(venv) $ pip install --requirement "requirements.txt"
  1. (Optional) Test Tensorflow Federated.
(venv) $ bazel test //tensorflow_federated/...
  1. Create a new project.
$ mkdir "/tmp/project"
$ cd "/tmp/project"

$ virtualenv --python python3 "venv"
$ source "venv/bin/activate"
(venv) $ pip install --upgrade pip

Note: To exit the virtual environment run deactivate.
  1. Install the pip package.
(venv) $ pip install --upgrade "/tmp/tensorflow_federated/tensorflow_federated-"*".whl"
  1. Test Tensorflow Federated.
(venv) $ python -c "import tensorflow_federated as tff; print(tff.federated_computation(lambda: 'Hello World')())"


Reference: https://www.tensorflow.org/federated/install

Upvotes: 1

Related Questions