There are a few common paths to take when manually building the nGraph Compiler stack from source code. Today nGraph supports various developers working on all parts of the Deep Learning stack, and the way you decide to build or install components ought to depend on the capabilities of your hardware, and how you intend to use it.
A “from scratch” source-code build of the nGraph Library enables the CPU,
Interpreter, and unit tests by default. See Building nGraph from source
for more detail.
A “from scratch” source-code build that defaults to the PlaidML backend
contains rich algorithm libraries akin to those that were previously available
only to developers willing to spend extensive time writing, testing, and
customizing kernels. An
NGRAPH_PLAIDML dist can function like a framework
that lets developers compose, train, and even deploy DL
models in their preferred language on neural networks of any size. This is
a good option if, for example, you are working on a laptop with a high-end
GPU that you want to use for compute. See Building nGraph-PlaidML from source
for instructions on how to build.
In either case, there are some prerequisites that your system will need to build from sources.
CentOS 7.4 64-bit
Ubuntu 16.04 or 18.04 (LTS) 64-bit
CMake 3.5.1 + GNU Make
Clear Linux* OS for Intel® Architecture version 28880+
Building nGraph from source¶
The default cmake procedure (no build flags) will
ngraph_dist to an OS-level location like
/usr/lib/ngraph_dist. Here we specify how to build locally to the
~/ngraph_dist with the cmake target
All of the nGraph Library documentation presumes that
installed locally. The system location can be used just as easily by
customizing paths on that system. See the
file to change or customize the default CMake procedure.
Ubuntu LTS build steps¶
The process documented here will work on Ubuntu* 16.04 (LTS) or on Ubuntu 18.04 (LTS).
Ensure you have installed the Prerequisites for Ubuntu*.
Clone the NervanaSystems
$ git clone https://github.com/NervanaSystems/ngraph.git $ cd ngraph
Create a build directory outside of the
ngraph/srcdirectory tree; somewhere like
ngraph/build, for example:
$ mkdir build && cd build
Generate the GNU Makefiles in the customary manner (from within the
builddirectory). This command enables ONNX support in the library and sets the target build location at
~/ngraph_dist, where it can be found easily.
$ cmake .. -DNGRAPH_ONNX_IMPORT_ENABLE=ON -DCMAKE_INSTALL_PREFIX=~/ngraph_dist
Other optional build flags – If running
clang-3.9, remember that you can also append
cmakewith the prebuilt LLVM option to speed-up the build. Another option if your deployment system has Intel® Advanced Vector Extensions (Intel® AVX) is to target the accelerations available directly by compiling the build as follows during the cmake step:
$ cmake .. [-DNGRAPH_TARGET_ARCH=skylake-avx512]
make installto install
libngraph.soand the header files to
$ make # note: make -j <N> may work, but sometimes results in out-of-memory errors if too many compilation processes are used $ make install
(Optional, requires doxygen, Sphinx, and breathe). Run
make htmlinside the
doc/sphinxdirectory of the cloned source to build a copy of the website docs locally. The low-level API docs with inheritance and collaboration diagrams can be found inside the
/docs/doxygen/directory. See the Contributing to documentation for more details about how to build documentation for nGraph.
CentOS 7.4 build steps¶
The process documented here will work on CentOS 7.4.
Ensure you have installed the Prerequisites for CentOS*, and update the system with yum.
$ sudo yum update
Install Cmake 3.4:
$ wget https://cmake.org/files/v3.4/cmake-3.5.0.tar.gz $ tar -xzvf cmake-3.5.0.tar.gz $ cd cmake-3.5.0 $ ./bootstrap --system-curl --prefix=~/cmake $ make && make install
Clone the NervanaSystems
ngraphrepo via HTTPS and use Cmake 3.5.0 to build nGraph Libraries to
~/ngraph_dist. This command enables ONNX support in the library (optional).
$ cd /opt/libraries $ git clone https://github.com/NervanaSystems/ngraph.git $ cd ngraph && mkdir build && cd build $ ~/cmake/bin/cmake .. -DCMAKE_INSTALL_PREFIX=~/ngraph_dist -DNGRAPH_ONNX_IMPORT_ENABLE=ON $ make && sudo make install
Building nGraph-PlaidML from source¶
The following instructions will create the
Ensure you have installed the Prerequisites for your OS.
Install the prerequisites for the backend. Our hybrid
NGRAPH_PLAIDMLbackend works best with Python3 versions. We recommend that you use a virtual environment, due to some of the difficulties that users have seen when trying to install outside of a venv.
$ sudo apt install python3-pip $ pip install plaidml $ plaidml-setup
Clone the source code, create and enter your build directory:
$ git clone https://github.com/NervanaSystems/ngraph.git $ cd ngraph && mkdir build && cd build
Prepare the CMake files as follows:
$ cmake .. -DCMAKE_INSTALL_PREFIX=~/ngraph_plaidml_dist -DNGRAPH_CPU_ENABLE=OFF -DNGRAPH_PLAIDML_ENABLE=ON
Run make and
make install. Note that if you are building outside a local or user path, you may need to run
make installas the root user.
$ make $ make install
This should create the shared library
libplaidml_backend.soand nbench. Note that if you built in a virtual environment and run
make checkfrom it, the Google Test may report failures. Full tests can be run when PlaidML devices are available at the machine level.
For more about working with the PlaidML backend from nGraph, see our API documentation PlaidML from nGraph.
Although we do not currently offer full support for the macOS platform, some configurations and features may work.
The repository includes two scripts (
maint/apply-code-format.sh) that are used respectively to check adherence
libngraph code formatting conventions, and to automatically reformat code
according to those conventions. These scripts require the command
clang-format-3.9 to be in your
PATH. Run the following commands
(you will need to adjust them if you are not using bash):
$ brew install firstname.lastname@example.org automake $ mkdir -p $HOME/bin $ ln -s /email@example.com/bin/clang-format $HOME/bin/clang-format-3.9 $ echo 'export PATH=$HOME/bin:$PATH' >> $HOME/.bash_profile
Testing the build¶
We use the googletest framework from Google for unit tests. The
command automatically downloaded a copy of the needed
gtest files when
it configured the build directory.
To perform unit tests on the install:
Create and configure the build directory as described in our Build and Test guide.
Enter the build directory and run
$ cd build/ $ make check