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

Building on Mac M3: Graphbolt forces OPENMP and CUDA on #7833

Open
GMNGeoffrey opened this issue Nov 8, 2024 · 2 comments
Open

Building on Mac M3: Graphbolt forces OPENMP and CUDA on #7833

GMNGeoffrey opened this issue Nov 8, 2024 · 2 comments

Comments

@GMNGeoffrey
Copy link

GMNGeoffrey commented Nov 8, 2024

🐛 Bug

I followed the instructions to build from source at https://docs.dgl.ai/install/index.html#macos and the build failed because it couldn't find OpenMP (which it was searching for even though that is explicitly set to OFF). The trace leads to the graphbolt directory CMakeLists.txt. USE_OPENMP is set to ON at this point for some reason (confirmed by sticking a message call in there). Throwing set(OPEN_MP OFF) immediately above this condition avoids the error, but then there are more errors stemming from graphbolt when building CUDA, even though USE_CUDA is OFF by default. Setting -DBUILD_GRAPHBOLT=OFF gets around these issues, but then the build fails trying to build tests/cpp/test_spmat_coo.cc which #includes omp.h. Setting -DBUILD_CPP_TEST=OFF got around this issue.

To Reproduce

Steps to reproduce the behavior:

  1. On Mac M3, create a fresh clone of dgl
  2. Run commands to build from the documentation:
mkdir build
cd build
cmake -DUSE_OPENMP=off -DUSE_LIBXSMM=OFF ..
make -j4 # or -j16 or whatever if you have the cores
  1. Get error about failing to find OpenMP:
[ 36%] Built target tensoradapter_pytorch
CMake Error at /Users/gcmn/src/dgl/.venv/lib/python3.12/site-packages/cmake/data/share/cmake-3.30/Modules/FindPackageHandleStandardArgs.cmake:233 (message):
  Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS OpenMP_C_LIB_NAMES)
Call Stack (most recent call first):
  /Users/gcmn/src/dgl/.venv/lib/python3.12/site-packages/cmake/data/share/cmake-3.30/Modules/FindPackageHandleStandardArgs.cmake:603 (_FPHSA_FAILURE_MESSAGE)
  /Users/gcmn/src/dgl/.venv/lib/python3.12/site-packages/cmake/data/share/cmake-3.30/Modules/FindOpenMP.cmake:600 (find_package_handle_standard_args)
  CMakeLists.txt:91 (find_package)

-- Configuring incomplete, errors occurred!
make[2]: *** [CMakeFiles/graphbolt] Error 1
make[1]: *** [CMakeFiles/graphbolt.dir/all] Error 2

(aside: it's a bit weird that the stack trace here only lists the path as CMakeLists.txt, rather than graphbolt/CMakeLists.txt. It appears that a separate CMake configure step for graphbolt is getting invoked as part of the build step??).

  1. Hack USE_OPENMP OFF. I originally just put set(USE_OPENMP OFF) right before the if condition, but it also works to change the default for the option. You need to manually delete the separate build directory the graphbolt sub-build created though.
rm -rf ./* ../graphbolt/build  # from build/
cmake -DUSE_OPENMP=off -DUSE_LIBXSMM=OFF ..
make -j16
  1. Now you get an error about redefinition of strstr.
In file included from /Users/gcmn/src/dgl/graphbolt/src/cache_policy.cc:20:
In file included from /Users/gcmn/src/dgl/graphbolt/src/./cache_policy.h:28:
In file included from /Users/gcmn/src/dgl/graphbolt/../third_party/cccl/libcudacxx/include/cuda/std/atomic:41:
In file included from /Users/gcmn/src/dgl/graphbolt/../third_party/cccl/libcudacxx/include/cuda/std/__atomic/wait/polling.h:26:
In file included from /Users/gcmn/src/dgl/graphbolt/../third_party/cccl/libcudacxx/include/cuda/std/__atomic/types.h:24:
In file included from /Users/gcmn/src/dgl/graphbolt/../third_party/cccl/libcudacxx/include/cuda/std/__atomic/types/base.h:25:
In file included from /Users/gcmn/src/dgl/graphbolt/../third_party/cccl/libcudacxx/include/cuda/std/__atomic/types/common.h:28:
In file included from /Users/gcmn/src/dgl/graphbolt/../third_party/cccl/libcudacxx/include/cuda/std/detail/libcxx/include/cstring:72:
/Users/gcmn/src/dgl/graphbolt/../third_party/cccl/libcudacxx/include/cuda/std/detail/libcxx/include/string.h:142:75: error: redefinition of 'strstr'
inline _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_PREFERRED_OVERLOAD char* strstr(char* __s1, const char* __s2)
                                                                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/c++/v1/string.h:104:63: note: previous definition is here
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD char* strstr(char* __s1, const char* __s2) {
                                                              ^
10 errors generated.
make[5]: *** [CMakeFiles/graphbolt_pytorch_2.5.1.dir/src/cache_policy.cc.o] Error 1
make[4]: *** [CMakeFiles/graphbolt_pytorch_2.5.1.dir/all] Error 2
make[3]: *** [all] Error 2
make[2]: *** [CMakeFiles/graphbolt] Error 2
make[1]: *** [CMakeFiles/graphbolt.dir/all] Error 2
  1. Try again with graphbolt off
rm -rf ./* ../graphbolt/build  # from build/
cmake -DUSE_OPENMP=off -DUSE_LIBXSMM=OFF -DBUILD_GRAPHBOLT=OFF ..
make -j16
  1. Now you get an error about OpenMP in a test:
/Users/gcmn/src/dgl/tests/cpp/test_spmat_coo.cc:4:10: fatal error: 'omp.h' file not found
#include <omp.h>
         ^~~~~~~
1 error generated.
make[2]: *** [CMakeFiles/runUnitTests.dir/tests/cpp/test_spmat_coo.cc.o] Error 1
  1. Try again without c++ tests
rm -rf ./* # from build/
cmake -DUSE_OPENMP=OFF -DUSE_LIBXSMM=OFF -DBUILD_GRAPHBOLT=OFF -DBUILD_CPP_TEST=OFF ..
make -j16
  1. Success!

Expected behavior

A build with USE_OPENMP and USE_CUDA set to OFF should not build or look for OpenMP or CUDA and should not build C++ tests that require OpenMP.

Environment

  • DGL Version (e.g., 1.0): HEAD (88f109f)
  • Backend Library & Version (e.g., PyTorch 0.4.1, MXNet/Gluon 1.3): PyTorch 2.5.1 (pip)
  • OS (e.g., Linux): macOS Sonoma 14.4
  • How you installed DGL (conda, pip, source): building from source
  • Build command you used (if compiling from source): (see above)
  • Python version: 3.12.7
  • CUDA/cuDNN version (if applicable): N/A
  • GPU models and configuration (e.g. V100): Apple M3
  • Any other relevant information: N/A
Copy link

github-actions bot commented Dec 8, 2024

This issue has been automatically marked as stale due to lack of activity. It will be closed if no further activity occurs. Thank you

@GMNGeoffrey
Copy link
Author

Given that nothing has changed, I'm pretty sure this is still an issue. That test that directly includes omp.h doesn't need to as it's already including the DGL shims over OpenMP that conditionally include the headers based on build settings. Happy to send a PR if there's someone to review it.

The other issue is that while Graphbolt has a USE_CUDA option and guards a lot of Cuda-specific stuff behind it, it uses cccl headers even when that option is turned off. Not really sure how to fix that other than requiring USE_CUDA for BUILD_GRAPHBOLT, which was obviously not the intent. Perhaps it could use std:: instead of ::cuda::std and only conditionally include that header (I haven't tested if that would fix the problem).

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

1 participant