Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot compile standalone example on macOS #70

Open
conradkun opened this issue Dec 18, 2023 · 1 comment
Open

Cannot compile standalone example on macOS #70

conradkun opened this issue Dec 18, 2023 · 1 comment

Comments

@conradkun
Copy link

Hi,

I am interested in using the Yggdrasil library for a C++ project, but I am having issues compiling the dylib on macOS.

In fact, I am not even able to compile the standalone example provided. Given the latest commit (as of Dec 18), I have tried modifying the compile_and_run.sh file so that line 29 reads:

bazel build --config=macos //:beginner_cc

Nevertheless, I get an error related to @org_tensorflow being unresolvable:

(...)
[1 / 1] checking cached actions
 665   │     Fetching repository @@bazel_tools~cc_configure_extension~local_config_cc; starting
 666   │     Fetching repository @@rules_java; starting
 667   │     Fetching https://github.com/boostorg/math/archive/refs/tags/boost-1.83.0.tar.gz
 668   │     Fetching https://github.com/protocolbuffers/protobuf/archive/refs/tags/v3.19.6.zip
 669   │     Fetching https://github.com/bazelbuild/rules_java/releases/download/6.0.0/rules_java-6.0.0.tar.gz
 670   │ ERROR: no such package '@@org_tensorflow//tensorflow/core': The repository '@@org_tensorflow' could not be resolved: Repository '@@org_tensorflow' is not defined
 671   │ Analyzing: target //:beginner_cc (109 packages loaded, 663 targets configured)
 672   │     currently loading: @@com_google_protobuf//
 673   │ [1 / 1] checking cached actions
 674   │     Fetching repository @@bazel_tools~cc_configure_extension~local_config_cc; starting
 675   │     Fetching https://github.com/boostorg/math/archive/refs/tags/boost-1.83.0.tar.gz
 676   │     Fetching https://github.com/protocolbuffers/protobuf/archive/refs/tags/v3.19.6.zip
 677   │     Fetching https://github.com/bazelbuild/rules_java/releases/download/6.0.0/rules_java-6.0.0.tar.gz
 678   │ ERROR: /private/var/tmp/_bazel_c.cardona/e5bb2b2198d9d78378b014e5c1a97558/external/ydf/yggdrasil_decision_forests/dataset/tensorflow/BUILD:8:15: no such package '@@org_tensorflow//t
       │ ensorflow/core': The repository '@@org_tensorflow' could not be resolved: Repository '@@org_tensorflow' is not defined and referenced by '@@ydf//yggdrasil_decision_forests/dataset/t
       │ ensorflow:tensorflow'
 679   │ Analyzing: target //:beginner_cc (109 packages loaded, 663 targets configured)
 680   │     currently loading: @@com_google_protobuf//
 681   │ [1 / 1] checking cached actions
 682   │     Fetching repository @@bazel_tools~cc_configure_extension~local_config_cc; starting
 683   │     Fetching https://github.com/boostorg/math/archive/refs/tags/boost-1.83.0.tar.gz
 684   │     Fetching https://github.com/protocolbuffers/protobuf/archive/refs/tags/v3.19.6.zip
 685   │     Fetching https://github.com/bazelbuild/rules_java/releases/download/6.0.0/rules_java-6.0.0.tar.gz
 686   │ ERROR: Analysis of target '//:beginner_cc' failed; build aborted: Analysis failed
 687   │ Analyzing: target //:beginner_cc (109 packages loaded, 663 targets configured)
 688   │     currently loading: @@com_google_protobuf//
 689   │ [1 / 1] checking cached actions
 690   │     Fetching repository @@bazel_tools~cc_configure_extension~local_config_cc; starting
 691   │     Fetching https://github.com/boostorg/math/archive/refs/tags/boost-1.83.0.tar.gz
 692   │     Fetching https://github.com/protocolbuffers/protobuf/archive/refs/tags/v3.19.6.zip
 693   │     Fetching https://github.com/bazelbuild/rules_java/releases/download/6.0.0/rules_java-6.0.0.tar.gz
 694   │ INFO: Elapsed time: 58.465s, Critical Path: 0.14s
 695   │ Analyzing: target //:beginner_cc (109 packages loaded, 663 targets configured)
 696   │     currently loading: @@com_google_protobuf//
 697   │ [1 / 1] checking cached actions
 698   │     Fetching repository @@bazel_tools~cc_configure_extension~local_config_cc; starting
 699   │     Fetching https://github.com/boostorg/math/archive/refs/tags/boost-1.83.0.tar.gz
 700   │     Fetching https://github.com/protocolbuffers/protobuf/archive/refs/tags/v3.19.6.zip
 701   │     Fetching https://github.com/bazelbuild/rules_java/releases/download/6.0.0/rules_java-6.0.0.tar.gz
 702   │ INFO: 1 process: 1 internal.
 703   │ Analyzing: target //:beginner_cc (109 packages loaded, 663 targets configured)
 704   │     currently loading: @@com_google_protobuf//
 705   │ [1 / 1] checking cached actions
 706   │     Fetching repository @@bazel_tools~cc_configure_extension~local_config_cc; starting
 707   │     Fetching https://github.com/boostorg/math/archive/refs/tags/boost-1.83.0.tar.gz
 708   │     Fetching https://github.com/protocolbuffers/protobuf/archive/refs/tags/v3.19.6.zip
 709   │     Fetching https://github.com/bazelbuild/rules_java/releases/download/6.0.0/rules_java-6.0.0.tar.gz
 710   │ ERROR: Build did NOT complete successfully
 711   │ FAILED:
 712   │     Fetching repository @@bazel_tools~cc_configure_extension~local_config_cc; starting
 713   │     Fetching https://github.com/boostorg/math/archive/refs/tags/boost-1.83.0.tar.gz
 714   │     Fetching https://github.com/protocolbuffers/protobuf/archive/refs/tags/v3.19.6.zip
 715   │     Fetching https://github.com/bazelbuild/rules_java/releases/download/6.0.0/rules_java-6.0.0.tar.gz
 716   │ FAILED:
 717   │     Fetching repository @@bazel_tools~cc_configure_extension~local_config_cc; starting
 718   │     Fetching https://github.com/boostorg/math/archive/refs/tags/boost-1.83.0.tar.gz
 719   │     Fetching https://github.com/protocolbuffers/protobuf/archive/refs/tags/v3.19.6.zip
 720   │     Fetching https://github.com/bazelbuild/rules_java/releases/download/6.0.0/rules_java-6.0.0.tar.gz

I saw that in line 19 of WORKSPACE there is a flag that seems to exclude tensorflow from the workspace, so I tried removing that. Unfortunately, it did not solve the issue and a similar error related to tensorflow popped up. I have admittedly little idea of how bazel works and would appreciate any help you could provide. Thank you!

@rstz
Copy link
Collaborator

rstz commented Dec 18, 2023

Hi, thanks for reporting this, that's a documentation bug / a bug in the compile_and_run script.

If you do not need TensorFlow support (i.e. TFRecord files), you can compile with

# running from the top directory of the repository
bazel build --config=macos  --define=use_ydf_tensorflow_proto=1 //examples:beginner_cc
./bazel-bin/examples/beginner_cc   --dataset_dir=yggdrasil_decision_forests/test_data/dataset   --output_dir=/tmp/yggdrasil_decision_forest

If you need TensorFlow support, you need to override the WORKSPACE file with WORKSPACE_WITH_TF, i.e.

# running from the top directory of the repository
cp WORKSPACE_WITH_TF WORKSPACE
bazel build --config=macos  //examples:beginner_cc
./bazel-bin/examples/beginner_cc   --dataset_dir=yggdrasil_decision_forests/test_data/dataset   --output_dir=/tmp/yggdrasil_decision_forest

Compilation with TensorFlow support will take more time (just downloading TF + dependencies probably takes a few minutes).

I'll keep this open until the documentation and script are updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants