BUILDING.md 1.6 KB
Newer Older
1 2 3 4
# Building the Python API for nGraph

## Building nGraph Python Wheels

Leona C's avatar
Leona C committed
5
If you want to try a newer version of nGraph's Python API than is available 
Leona C's avatar
Leona C committed
6 7 8
from PyPI, you can build the latest version from source code. This process is 
very similar to what is outlined in our [ngraph_build] instructions with two 
important differences:
9 10 11 12 13 14 15 16 17 18 19 20

1. You must specify: `-DNGRAPH_PYTHON_BUILD_ENABLE=ON` and `-DNGRAPH_ONNX_IMPORT_ENABLE=ON` 
   when running `cmake`.

2. Instead of running `make`, use the command `make python_wheel`.

    `$ cmake ../ -DNGRAPH_PYTHON_BUILD_ENABLE=ON -DNGRAPH_ONNX_IMPORT_ENABLE=ON -DNGRAPH_USE_PREBUILT_LLVM=ON`

    `$ make python_wheel`

After this procedure completes, the `ngraph/build/python/dist` directory should 
contain the Python packages of the version you cloned. For example, if you 
Leona C's avatar
Leona C committed
21
checked out and built `0.21` for Python 3.7, you might see something like: 
22 23

    $ ls python/dist/
24 25
    ngraph-core-0.21.0rc0.tar.gz  
    ngraph_core-0.21.0rc0-cp37-cp37m-linux_x86_64.whl  
26 27 28 29 30 31 32 33 34 35 36 37 38

### Using a virtualenv (optional)

You may wish to use a virutualenv for your installation.

    $ virtualenv -p $(which python3) venv
    $ source venv/bin/activate
    (venv) $

### Installing the wheel

You may wish to use a virutualenv for your installation.

39
    (venv) $ pip install ngraph/build/python/dist/ngraph_core-0.21.0rc0-cp37-cp37m-linux_x86_64.whl
40 41 42 43 44 45 46 47 48 49 50 51 52

## Running tests

Unit tests require additional packages be installed:

    (venv) $ cd ngraph/python
    (venv) $ pip install -r test_requirements.txt

Then run tests:

    (venv) $ pytest test/ngraph/

[ngraph_build]: http://ngraph.nervanasys.com/docs/latest/buildlb.html