Skip to content
This repository was archived by the owner on Jan 3, 2023. It is now read-only.
fboemer edited this page Oct 29, 2018 · 24 revisions

If the setup has already been done

TLDR, if the setup has already been done, here's the command to run

# Without TF
$ cd ~/repos/he-transformer/build
$ ./test/unit-test --gtest_filter="HE_HEAAN.ab"

# With TF
# activate python env with tf and ngraph installed
$ source ~/repos/venvs/he3/bin/activate
$ cd ~/repos/ngraph-tf/examples/
$ NGRAPH_TF_BACKEND=HE_SEAL python axpy.py
$ deactivate

Build ngraph-he

1. Build HE Transformer without TF

  • Create build directory
cd ~/repos/he-transformer/
mkdir build
cd build
  • To build without ngraph-tf, we can build nGraph automatically
cmake ..
make -j
  • Run C++ Native example: in build
./test/unit-test --gtest_filter="HE_SEAL.ab"
./test/unit-test --gtest_filter="HE_HEAAN.ab"

2. Build HE Transformer with TF

2.1 Create python virtualenv and install TF

mkdir -p ~/venvs
virtualenv ~/venvs/he3 -p python3
source ~/venvs/he3/bin/activate
pip install tensorflow

2.2 Build ngraph-tf

Note: must be done inside the virtual env

  • Create build directory
cd ~/repos
git clone https://github.com/NervanaSystems/ngraph-tf.git
cd ~/repos/ngraph-tf/
git checkout v0.7.0-rc0
mkdir build
cd build
cmake ..
  • Build and install
make -j
make install
pip install python/dist/ngraph-0.7.0-py2.py3-none-linux_x86_64.whl
# Try importing -- this shouldn't crash
python -c "import ngraph"

2.3 Build he-transformer

Note: must be done inside the virtualenv

cd ~/repos/he-transformer
# Clean up
rm -rf build
mkdir build
cd build
# Config, change the corresponding folder location below
cmake .. -DCMAKE_BUILD_TYPE=Debug \
        -DPREBUILD_NGRAPH_INCLUDE_DIR=$HOME/repos/ngraph-tf/build/ngraph/ngraph_dist/include \
        -DPREBUILD_NGRAPH_LIB_DIR=$HOME/venvs/he3/lib/python3.5/site-packages/ngraph
# Or let python tell us the site-package
cmake .. -DCMAKE_BUILD_TYPE=Debug \
        -DPREBUILD_NGRAPH_INCLUDE_DIR=~/repos/ngraph-tf/build/ngraph/ngraph_dist/include \
        -DPREBUILD_NGRAPH_LIB_DIR=`python -c "import sys; print(sys.path[-1])"`/ngraph
# Installs libhe_backend.so into the python site-packages
make -j
make install

# If you run into errors relating to `abi:cxx11`, try adding `-D_GLIBCXX_USE_CXX11_ABI=0` or `-D_GLIBCXX_USE_CXX11_ABI=1` to the cmake command

2.4 Run TF python model

Note: must be done inside the virtualenv

# source activate virtualenv first
source ~/repos/venvs/he3/bin/activate
cd ~/repos/he-transformer/examples

# run on ngraph-CPU
python axpy.py

# run on SEAL:BFV
NGRAPH_TF_BACKEND=HE:SEAL:BFV python axpy.py

# run on SEAL:CKKS
NGRAPH_TF_BACKEND=HE:SEAL:CKKS python axpy.py
Clone this wiki locally