3. TensorFlow 2 setup

Warning

The versions of TensorFlow included in Poplar SDK 2.5 and earlier are not compatible with protobuf version 4 (see TensorFlow issue #56077). When you install a TensorFlow wheel from the Poplar SDK, you must ensure you have a compatible version of protobuf, downgrading if necessary.

For TensorFlow 2:

$ python -m pip install "protobuf>=3.8.0,<3.20" --force-reinstall

You can do this before or after installing the Graphcore TensorFlow wheel.

Note

You should activate the Python virtual environment you created for TensorFlow 2 (Section 2.6, Create a Python virtual environment) before performing the setup in this section.

3.1. Install TensorFlow 2 wheel

This section describes how to install the wheel file containing the Graphcore distribution of TensorFlow 2.

There are two TensorFlow 2 wheels, one for AMD processors and one for Intel processors. Check which processor is used on your system by running:

$ lscpu | grep name

Install the Graphcore TensorFlow 2 distribution for the processor you found in the previous step using a command similar to the following:

$ python -m pip install $SDK_DIR/tensorflow-[ver]+[platform].whl

where `$SDK_DIR` is the location of the Poplar SDK (:numref:`sdk_location`), ``[ver]`` is the version of the Graphcore port of TensorFlow 2 and ``[platform]`` defines the host processor and operating system for the TensorFlow build.

An example of the TensorFlow 2 wheel file for an AMD processor is:

tensorflow-2.6.3+gc3.0.0+236842+d084e493702+amd_znver1-cp38-cp38-linux_x86_64.whl

3.2. Install Keras wheel

In the TensorFlow 2.6 release, Keras was moved into a separate pip package. In the Poplar SDK 2.6 release, which includes the Graphcore distribution of TensorFlow 2.6, there is a Graphcore distribution of Keras which includes IPU-specific extensions.

This section describes how to install the wheel file containing the Graphcore distribution of Keras.

Note

The Keras wheel must be installed after the TensorFlow wheel, but before the TensorFlow Addons wheel.

To install the Keras wheel, use a command similar to:

$ python -m pip install --force-reinstall --no-deps $SDK_DIR/keras-<tf-ver>*.whl

where <tf-ver> is the TensorFlow 2 version.

An example of the Keras wheel file for for TensorFlow 2.6 for the IPU for Poplar SDK 2.6 is:

keras-2.6.0+gc3.0.0+236851+1744557f-py2.py3-none-any.whl

3.3. Install TensorFlow 2 Addons wheel

This section describes how to install the wheel file containing a collection of add-ons for the Graphcore distribution of TensorFlow 2.

IPU TensorFlow Addons is a collection of add-ons created for the Graphcore port of TensorFlow. These include layers and optimizers for Keras, as well as legacy TensorFlow layers. For more information, refer to the section on :ref:`IPU TensorFlow Addons <tensorflow2:ipu tensorflow addons python api>`_ in the TensorFlow 2 user guide.

Note

  • The IPU TensorFlow 2 Addons wheel file is only available in Poplar SDK 2.4 and later.

  • There are separate Addons wheel files for TensorFlow 1 and TensorFlow 2.

Install the IPU TensorFlow 2 Addons wheel using a command similar to the following:

$ python -m pip install  $SDK_DIR/ipu_tensorflow_addons-[ver]+X+X+X-X-X-X.whl

where $SDK_DIR is the location of the Poplar SDK (Section 2.4, Define environment variables), [ver] is the version of the Graphcore port of TensorFlow 2.

An example of the IPU TensorFlow 2 Addons wheel file is:

ipu_tensorflow_addons-2.6.3+gc3.0.0+236851+2e46901-py3-none-any.whl