2. Quick start for experts
Ensure you have completed the steps described in the getting started guide for your system as defined in the Prerequisites section before completing the steps in this section.
The setup for TensorFlow 1 depends on whether your system is running Ubuntu 18.04 or Ubuntu 20.04.
You can check which OS you are running with:
$ lsb_release -a
2.1. Ubuntu 18.04
2.1.1. Enable Poplar SDK
$ source [path-to-sdk]/enable
$ popc --version
where [path-to-sdk]
is the path to the Poplar SDK. Section 3.1.1, Enable Poplar SDK contains details of the SDK paths for different systems and what to do if you are using a version of the SDK earlier than 2.6.
2.1.2. Create and enable a Python virtual environment
$ virtualenv -p python[py_ver] ~/[base_dir]/[venv_name]
$ source ~/[base_dir]/[venv_name]/bin/activate
where [base_dir]
is a location of your choice and [venv_name]
is the name of the directory that will be created for the virtual environment. [py_ver]
is the version of Python you are using and it depends on your OS.
On Ubuntu 18 systems we support Python 3.6, and on Ubuntu 20 systems we support Python 3.8. You can get more information about the versions of tools supported in the Poplar SDK for different operating systems in the Poplar SDK 3.3.0 Release Notes. You can check which OS you are running with lsb_release -a
.
2.1.3. Install the TensorFlow 1 wheels and validate
$ python -m pip install ${POPLAR_SDK_ENABLED?}/../tensorflow-1.*+amd_*.whl
$ python -m pip install ${POPLAR_SDK_ENABLED?}/../ipu_tensorflow_addons-1.*.whl
$ python3 -c "from tensorflow.python import ipu"
$ python3 -c "ipu_tensorflow_addons.keras import layers"
$ python -m pip install ${POPLAR_SDK_ENABLED?}/../tensorflow-1.*+intel_*.whl
$ python -m pip install ${POPLAR_SDK_ENABLED?}/../ipu_tensorflow_addons-1.*.whl
$ python3 -c "from tensorflow.python import ipu"
$ python3 -c "ipu_tensorflow_addons.keras import layers"
See Section 3.1.3, Install the TensorFlow 1 wheels and validate for details.
2.1.4. Clone Graphcore Tutorials repo
You need the Graphcore tutorials repository to run the example application and for convenience we set an environment variable to the tutorials directory.
$ cd ~/[base dir]
$ git clone https://github.com/graphcore/tutorials.git
$ cd tutorials
$ git checkout sdk-release-[poplar-ver]
$ export POPLAR_TUTORIALS_DIR=$(pwd)
where [base_dir]
is a location of your choice and [poplar-ver]
is the version of the Poplar SDK you enabled in Section 2.1.1, Enable Poplar SDK.
2.1.5. Run the application
$ cd ${POPLAR_TUTORIALS_DIR?}/simple_applications/tensorflow/mnist
$ pip install -r requirements.txt
$ python3 mnist_tf.py
2.1.6. Try out other applications
Clone the examples repo so you can try out other examples. For convenience we set an environment variable to the examples directory
$ cd ~/[base dir]
$ git clone https://github.com/graphcore/examples.git
$ cd examples
$ export POPLAR_EXAMPLES_DIR=$(pwd)
where [base_dir]
is a location of your choice.
If you are using a Poplar SDK other than the current release, you will need to checkout the tag corresponding to the SDK version. For example:
$ git checkout v[poplar-ver] # select Poplar SDK version
Where [poplar-ver]
is the version of the Poplar SDK you enabled in Section 2.1.1, Enable Poplar SDK.
There may be changes that were made to the examples after the SDK release tag was created. If you want to access those, but still ensure compatibility with the version of the Poplar SDK you are using, then you will need to checkout the commit immediately prior to the tag for the following SDK version.
2.1.7. Exit the virtual environment
When you are done, exit the virtual environment with:
$ deactivate
2.2. Ubuntu 20.04
Ubuntu 20.04 does not natively support TensorFlow 1. This means that you need to run TensorFlow 1 applications in an Ubuntu 18.04 Docker container. Refer to Using IPUs from Docker for more information.
The following commands provide an example of how to pull the latest TensorFlow 1 image from Docker Hub, and then instantiate the container(Listing 2.1):
$ docker pull graphcore/tensorflow:1-intel
$ gc-docker -- -ti -v /home/ubuntu/graphcore:/graphcore -e IPUOF_VIPU_API_HOST -e IPUOF_VIPU_API_PARTITION_ID graphcore/tensorflow:1-intel
Thereafter, you can complete the following from within the container: