Integrate Supported Frameworks

MXNet*

Compile MXNet with nGraph

Important

These instructions pick up from where the Install installation instructions left off, so they presume that your system already has the library installed at $HOME/ngraph_dist as the default location. If the nGraph library code has not yet been installed to your system, please go back and return here to finish compiling MXNet with libngraph.

  1. Set the LD_LIBRARY_PATH path to the location where we built the nGraph libraries:

    export LD_LIBRARY_PATH=$HOME/ngraph_dist/lib/
    
  2. Add the MXNet prerequisites to your system, if the system doesn’t have them already. These requirements are Ubuntu*-specific.

    $ sudo apt-get install -y libopencv-dev curl libatlas-base-dev python
    python-pip python-dev python-opencv graphviz python-scipy python-sklearn
    libopenblas-dev
    
  3. Clone the ngraph-mxnet repository recursively

    $ git clone --recursive git@github.com:NervanaSystems/ngraph-mxnet.git
    
  4. Edit the make/config.mk file from the repo we just checked out to set the USE_NGRAPH option (line 100) to true with 1 and set the NGRAPH_DIR (line 101) to point to the installation location target where the nGraph library was installed:

    USE_NGRAPH = 1
    NGRAPH_DIR = $(HOME)/ngraph_dist
    
  5. Ensure that settings on the config file are disabled for USE_MKL2017 (line 113) and USE_NNPACK (line 120).

    # whether use MKL2017 library
    USE_MKL2017 = 0
    
    # whether use MKL2017 experimental feature for high performance
    # Prerequisite USE_MKL2017=1
    USE_MKL2017_EXPERIMENTAL = 0
    
    # whether use NNPACK library
    USE_NNPACK = 0
    
  6. Finally, compile MXNet with Intel® nGraph:

    $ make -j $(nproc)
    
  7. After successfully running make, install the Python integration packages that your MXNet build needs to run a training example.

    $ cd python && pip install -e . && cd ../
    
  8. Confirm a successful integration by running the MNIST training example:

    $ python example/image-classification/train_mnist.py
    

TensorFlow*

See the ngraph tensorflow bridge README for how to install the nGraph-TensorFlow bridge.

neon™

Use neon as a frontend for nGraph backends

neon is an open source Deep Learning framework that has a history of being the fastest framework for training CNN-based models with GPUs. Detailed info about neon’s features and functionality can be found in the neon docs. This section covers installing neon on an existing system that already has an ngraph_dist installed.

Important

The numbered instructions below pick up from where the Install instructions left off, and they presume that your system already has the ngraph library installed installed at $HOME/ngraph_dist as the default location. If the nGraph library code has not yet been installed to your system, you can follow the instructions on the ngraph-neon python README to install everything at once.

  1. Set the NGRAPH_CPP_BUILD_PATH and the LD_LIBRARY_PATH path to the location where you built the nGraph libraries. (This example shows the default location):

    export NGRAPH_CPP_BUILD_PATH=$HOME/ngraph_dist/
    export LD_LIBRARY_PATH=$HOME/ngraph_dist/lib/
    
  2. The neon framework uses the pip package manager during installation; install it with Python version 3.5 or higher:

    $ sudo apt-get install python3-pip python3-venv
    $ python3 -m venv frameworks
    $ cd frameworks
    $ . bin/activate
    (frameworks) ~/frameworks$
    
  3. Go to the “python” subdirectory of the ngraph repo we cloned during the previous Install, and complete these actions:

    (frameworks)$ cd /opt/libraries/ngraph/python
    (frameworks)$ git clone --recursive -b allow-nonconstructible-holders https://github.com/jagerman/pybind11.git
    (frameworks)$ export PYBIND_HEADERS_PATH=/opt/libraries/ngraph/python/pybind11
    (frameworks)$ pip install -U .
    
  4. Finally we’re ready to install the neon integration:

    (frameworks)$ git clone git@github.com:NervanaSystems/ngraph-neon
    (frameworks)$ cd ngraph-neon
    (frameworks)$ make install
    
  5. To test a training example, you can run the following from ngraph-neon/examples/cifar10

    (frameworks)$ python cifar10_conv.py