Giter Club home page Giter Club logo

ngraph-bridge's Introduction

Intel(R) nGraph(TM) Compiler and runtime for TensorFlow*

This repository contains the code needed to enable Intel(R) nGraph(TM) Compiler and runtime engine for TensorFlow. Use it to speed up your TensorFlow training and inference workloads. The nGraph Library and runtime suite can also be used to customize and deploy Deep Learning inference models that will "just work" with a variety of nGraph-enabled backends: CPU, GPU, and custom silicon like the Intel(R) Nervana(TM) NNP.

License Build Status Build Status Build Status

Linux instructions

Option 1: Use a pre-built nGraph-TensorFlow bridge

  1. You can install TensorFlow and nGraph using virtualenv or in the system Python location.

  2. Install TensorFlow v1.14.0rc0:

     pip install -U tensorflow==1.14.0rc0
    
  3. Install nGraph-TensorFlow bridge:

     pip install -U ngraph-tensorflow-bridge
    

Option 2: Build nGraph bridge with binary TensorFlow installation

To use the latest version build and install nGraph using the following steps:

  1. You need to have virtualenv installed on your system to be able build ngraph-bridge bridge. The virtualenv is configured and used by the build script but not required for running ngraph-bridge.

  2. Please ensure that you have gcc 4.8 version installed on your system. The nGraph bridge links with the TensorFlow libraries that are build with gcc 4.8 version of the toolchain.

  3. Next run the following Python script to download TensorFlow, and build nGraph and the bridge. Please use Python 3.5:

     python3 build_ngtf.py --use_prebuilt_tensorflow
    
  4. Now test the build by executing the following commands:

     source build_cmake/venv-tf-py3/bin/activate
     PYTHONPATH=`pwd` python3 test/ci/buildkite/test_runner.py \
             --backend CPU \
             --artifacts ./build_cmake/artifacts/ \
             --test_resnet
    

Option 3: Build nGraph bridge from source

if you are planning to contribute or planning to run unit tests install the nGraph bridge using the TensorFlow source tree as follows:

Prepare the build environment

The installation prerequisites are the same as described in the TensorFlow prepare environment for linux.

  1. TensorFlow uses a build system called "bazel". The version of the bazel is determined by the TensorFlow team. For the current version, use [bazel version 0.25.2].

     wget https://github.com/bazelbuild/bazel/releases/download/0.25.2/bazel-0.25.2-installer-linux-x86_64.sh      
     bash bazel-0.25.2-installer-linux-x86_64.sh --user
    
  2. Add and source the bin path to your ~/.bashrc file in order to be able to call bazel from the user's installation we set up:

     export PATH=$PATH:~/bin
     source ~/.bashrc   
    
  3. Additionally, you need to install cmake version 3.1 or higher and gcc 4.8 or higher.

Build

  1. Once TensorFlow's dependencies are installed, clone ngraph-bridge repo:

     git clone https://github.com/tensorflow/ngraph-bridge.git
     cd ngraph-bridge
     git checkout master
    
  2. Next run the following Python script to build TensorFlow, nGraph and the bridge. Please use Python 3.5:

     python3 build_ngtf.py
    

Once the build finishes, a new virtualenv directory is created in the build_cmake/venv-tf-py3. The build artifacts i.e., the ngraph_tensorflow_bridge-<VERSION>-py2.py3-none-manylinux1_x86_64.whl is created in the build_cmake/artifacts directory.

  1. Test the installation by running the following command:

     python3 test_ngtf.py
    

This command will run all the C++ and python unit tests from the ngraph-bridge source tree. Additionally this will also run various TensorFlow python tests using nGraph.

  1. To use the ngraph-tensorflow bridge, activate this virtual environment to start using nGraph with TensorFlow.

     source build_cmake/venv-tf-py3/bin/activate
    

Once the build and installation steps are complete, you can start using TensorFlow with nGraph backends. Please note that you can also install the TensorFlow and nGraph bridge outside of virtualenv. The Python whl files are located in the build_cmake/artifacts/ and build_cmake/artifats/tensorflow directories, respectively. Select the help option of build_ngtf.py script to learn more about various build options and how to build other backends.

How to use nGraph with TensorFlow

  1. Test the installation by running the following command:

     python -c "import tensorflow as tf; print('TensorFlow version: ',tf.__version__);import ngraph_bridge; print(ngraph_bridge.__version__)"
    

    This will produce something like this:

     TensorFlow version:  1.14.0-rc0
     C Compiler version used in building TensorFlow:  7.3.0
     nGraph bridge version: b'0.14.0'
     nGraph version used for this build: b'0.20.0-rc.0+0995b71'
     TensorFlow version used for this build: v1.14.0-rc0-0-gf5ce1c00d4
     CXX11_ABI flag used for this build: 1
     nGraph bridge built with Grappler: False
     nGraph bridge built with Variables and Optimizers Enablement: False
    

    Note: The version of the ngraph-tensorflow-bridge is not going to be exactly the same as when you build from source. This is due to delay in the source release and publishing the corresponding Python wheel.

  2. You can try out the TensorFlow models by adding the following lines to your existing TensorFlow model scripts and running them the usual way:

     import ngraph_bridge
     ...
     config = tf.ConfigProto() # or your existing config
     config_ngraph_enabled = ngraph_bridge.update_config(config)
     sess = tf.Session(config=config_ngraph_enabled) # use the updated config in session creation
    

Detailed examples on how to use ngraph_bridge are located in the examples directory.

Using OS X

The build and installation instructions are identical for Ubuntu 16.04 and OS X. However, please note that the Python setup is not always the same across various Mac OS versions. TensorFlow build instructions recommend using Homebrew and often people use Pyenv. There is also Anaconda/Miniconda which some users prefer. Ensure that you can build TenorFlow successfully on OS X with a suitable Python environment prior to building nGraph.

Debugging

The pre-requisite for building nGraph using Option 3 is to be able to build TensorFlow from source. Often there are missing configuration steps for building TensorFlow. If you run into build issues, first ensure that you can build TensorFlow. For debugging run time issues, see the instructions provided in the diagnostics directory.

Support

Please submit your questions, feature requests and bug reports via GitHub issues.

How to Contribute

We welcome community contributions to nGraph. If you have an idea for how to improve it:

  • Share your proposal via GitHub issues.
  • Ensure you can build the product and run all the examples with your patch.
  • In the case of a larger feature, create a test.
  • Submit a pull request.
  • We will review your contribution and, if any additional fixes or modifications are necessary, may provide feedback to guide you. When accepted, your pull request will be merged to the repository.

About Intel(R) nGraph(TM)

See the full documentation here: http://ngraph.nervanasys.com/docs/latest

ngraph-bridge's People

Contributors

avijit-nervana avatar sayantan-nervana avatar crlishka avatar sindhu-nervana avatar jianyinglang avatar shresthamalik avatar kanvi-nervana avatar icarusmj12 avatar mingshan-wang avatar chaseadams509 avatar sharathns93 avatar kbalka avatar earhart avatar jbobba avatar indie avatar ransford2011 avatar yeonsily avatar dawnstone avatar fboemer avatar fengleitian avatar xwangintel avatar jiminha avatar kimjanik avatar lnguyen-nvn avatar sasadep avatar sachinmuradi avatar troiwill avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.