This directory contains a in-developent C++ port of Minigo.
The C++ Minigo port uses the Bazel build system. It depends on the Tensorflow C++ libraries, but we have not yet set up Bazel WORKSPACE and BUILD rules to automatically download and configure Tensorflow so (for now at least) you must perform a manual step to build the library:
./cc/configure_tensorflow.shIf you want to compile for CPU and not GPU, then change TF_NEED_CUDA to 0 in
configure_tensorflow.sh
This will automatically perform the first steps of
Installing Tensorflow from Sources
but instead of installing the Tensorflow package, it extracts the generated C++
headers into the cc/tensorflow subdirectory of the repo. The script then
builds the required Tensorflow shared libraries and copies them to the same
directory. The tensorflow cc_library build target in cc/BUILD pulls these
header & library files together into a format the Bazel understands how to link
against.
The C++ Minigo implementation requires that the board size be defined at compile
time, using the MINIGO_BOARD_SIZE preprocessor define. This allows us to
significantly reduce the number of heap allocations performed. However, it does
mean that you must specify the board size when compiling by invoking Bazel with
either --define=board_size=9 or --define=board_size=19.
This defines MINIGO_BOARD_SIZE when compiling the Minigo sources, but none of
their dependencies, which avoids unnecessarily recompiling Minigo's
dependencies when switching board size.
Pass --define=board_size=9 when invoking Bazel to build Minigo for a 9x9
board.
Pass --define=board_size=19 when invoking Bazel to build Minigo for a 19x19
board.
Minigo's C++ unit tests operate on both 9x9 and 19x19, and some tests are only enabled for a particular board size. Consequently, you must run the tests multiple times:
bazel test --define=board_size=9 cc/... && bazel test --define=board_size=19 cc/...The C++ Minigo binary requires the model to be provided in GraphDef binary proto format.
To run Minigo with a 9x9 model:
bazel build --config=minigo9 -c opt cc:main
bazel-bin/cc/main --model=$MODEL_PATHTo run Minigo with a 19x19 model:
< 39C0 div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="bazel build --config=minigo9 -c opt cc:main bazel-bin/cc/main --model=$MODEL_PATH">bazel build --config=minigo9 -c opt cc:main
bazel-bin/cc/main --model=$MODEL_PATH