2. General Setup

In order to run this example, you must:

  1. Log in to Graphcloud. Refer to the Graphcloud Access Quick Start for details.

  2. Set up the environment (this is also described in the Graphcloud Setup Quick Start). If you have already set up the environment, you can go directly to Section 3, PyTorch setup.

    The steps are:

    1. Create the environment variable for the SDK location (Section 2.1, Define SDK location).

    2. Source the enable.sh script for Poplar (Section 2.2, Enable Poplar).

    3. Source the enable.sh script for PopART. (Section 2.3, Enable PopART).

    4. Create a workspace directory (Section 2.4, Creating a workspace directory).

    5. Clone the Graphcore tutorials repository (Section 2.5, Installing the Graphcore tutorials).

    6. Create a new Python virtual environment (Section 2.6, Working with a Python virtual environment) if you don’t already have one for PyTorch.

    7. Activate the Python virtual environment (Section 2.6, Working with a Python virtual environment).

2.1. Define SDK location

In order to simplify working with the Poplar SDK, we define the location of the SDK as an environment variable (Listing 2.1).

Listing 2.1 Creating environment variable for SDK location
$ export SDKDIR=/opt/gc/poplar_sdk-ubuntu_18_04-[poplar_ver]+[build]

where [poplar_ver] is the software version number of the Poplar SDK and [build] is the build information.

2.2. Enable Poplar

You must source the Poplar enable script for TensorFlow 1, TensorFlow 2, PyTorch and PopART; also if you are working directly in the Poplar Graph Programming Framework.

$ source $SDKDIR/poplar-ubuntu_18_04-[poplar_ver]+[build]/enable.sh

where $SDKDIR is the location of the Poplar SDK (Section 2.1, Define SDK location), [poplar_ver] is the software version number of the Poplar SDK and [build] is the build information.

You can verify that Poplar has been successfully set up by running:

$ popc --version

This will display the version of the installed software.

If you attempt to run any Poplar software without having first sourced this script, you will get an error from the C++ compiler similar to the following (the exact message will depend on your code):

fatal error: 'poplar/Engine.hpp' file not found

Note

You must source the Poplar enable script for each new Bash shell. You can add this source command to your .bashrc to do this on a more permanent basis.

2.3. Enable PopART

You must source the PopART enable script if you are using PyTorch or PopART, but not if you are using TensorFlow or working directly in the Poplar Graph Programming Framework.

$ source $SDKDIR/popart-ubuntu_18_04-[poplar_ver]+[build]/enable.sh

where $SDKDIR is the location of the Poplar SDK (Section 2.1, Define SDK location), [poplar_ver] is the software version number of the Poplar SDK and [build] is the build information.

Note

You must source the PopART enable script for each new Bash shell. You can add this source command to your .bashrc to do this on a more permanent basis.

You can verify that PopART has been successfully set up by running:

$ python3 -c "import popart"

This will fail with the following error if PopART hasn’t been successfully configured:

ModuleNotFoundError: No module named 'popart'

2.4. Creating a workspace directory

\localdata contains a directory named with your username that only you can access. Create a workspace directory here and create a symbolic link to it in your home directory to make access easier.

$ mkdir /localdata/<username>/workspace
$ ln -s /localdata/<username>/workspace ~/workspace

2.5. Installing the Graphcore tutorials

There are several tutorials available in the Graphcore GitHub repository tutorials. These are listed in the Examples and Tutorials index.

  1. Clone the tutorials repository into the ~/workspace directory.

$ cd ~/workspace
$ git clone https://github.com/graphcore/tutorials.git
Cloning into 'tutorials'...

This will install the contents of the tutorials repository under ~/workspace/tutorials.

  1. Checkout the branch of the tutorials repository corresponding to the version of the Poplar SDK you have sourced.

$ git checkout sdk-release-[poplar-ver]

where [poplar-ver] is the version of the Poplar SDK that you have sourced in Section 2.2, Enable Poplar.

2.6. Working with a Python virtual environment

It is good practice to work in a different Python virtual environment for each framework or even for each application. This section describes how you create, activate and deactivate a Python virtual environment.

  1. Create a Python virtual environment.

$ virtualenv -p python3.6 ~/workspace/[venv_name]

where [venv_name] is the name of the virtual environment.

  1. Activate the virtual environment so you can use it.

$ source ~/workspace/[venv_name]/bin/activate

Now all subsequent installations will be local to that virtual environment.

  1. Deactivate the virtual environment with:

$ deactivate