cugraph icon indicating copy to clipboard operation
cugraph copied to clipboard

[BUG]: Some python files cannot be built.

Open gdaisukesuzuki opened this issue 1 year ago • 3 comments

Version

24.04

Which installation method(s) does this occur on?

Source

Describe the bug.

Some files under folder "python" cannot be built because the namespace "cuda" is not explicitly declared.

Solution: In the CMakeLists.txt related to the associated files, define the macro "LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE" to explicitly declare the namespace "cuda". The specific patch is as follows:

*** cugraph/python/pylibcugraph/pylibcugraph/components/CMakeLists.txt.orig     2024-03-27 20:20:25.448029849 +0900
--- cugraph/python/pylibcugraph/pylibcugraph/components/CMakeLists.txt  2024-03-27 20:21:27.852436026 +0900
***************
*** 16,21 ****
--- 16,22 ----
      _connectivity.pyx
  )
  set(linked_libraries cugraph::cugraph)
+ add_compile_definitions(LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE)
  
  rapids_cython_create_modules(
    CXX
*** cugraph/python/cugraph/cugraph/dask/comms/CMakeLists.txt.orig       2024-03-27 21:09:01.846013209 +0900
--- cugraph/python/cugraph/cugraph/dask/comms/CMakeLists.txt    2024-03-27 21:10:00.637135255 +0900
***************
*** 14,19 ****
--- 14,20 ----
  
  set(cython_sources comms_wrapper.pyx)
  set(linked_libraries cugraph::cugraph)
+ add_compile_definitions(LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE)
  rapids_cython_create_modules(
    CXX
    SOURCE_FILES "${cython_sources}"
*** cugraph/python/cugraph/cugraph/structure/CMakeLists.txt.orig        2024-03-27 21:14:40.418706851 +0900
--- cugraph/python/cugraph/cugraph/structure/CMakeLists.txt     2024-03-27 21:16:33.643957596 +0900
***************
*** 14,19 ****
--- 14,20 ----
  
  set(cython_sources graph_primtypes_wrapper.pyx graph_primtypes.pyx utils_wrapper.pyx)
  set(linked_libraries cugraph::cugraph)
+ add_compile_definitions(LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE)
  rapids_cython_create_modules(
    CXX
    SOURCE_FILES "${cython_sources}"
*** cugraph/python/cugraph/cugraph/dask/structure/CMakeLists.txt.orig   2024-03-27 21:20:20.454575148 +0900
--- cugraph/python/cugraph/cugraph/dask/structure/CMakeLists.txt        2024-03-27 21:20:50.815112728 +0900
***************
*** 14,19 ****
--- 14,20 ----
  
  set(cython_sources replication.pyx)
  set(linked_libraries cugraph::cugraph)
+ add_compile_definitions(LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE)
  rapids_cython_create_modules(
    CXX
    SOURCE_FILES "${cython_sources}"
*** cugraph/python/cugraph/cugraph/utilities/CMakeLists.txt.orig        2024-03-27 21:25:13.589826973 +0900
--- cugraph/python/cugraph/cugraph/utilities/CMakeLists.txt     2024-03-27 21:26:06.700790477 +0900
***************
*** 14,19 ****
--- 14,20 ----
  
  set(cython_sources path_retrieval_wrapper.pyx)
  set(linked_libraries cugraph::cugraph)
+ add_compile_definitions(LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE)
  rapids_cython_create_modules(
    CXX
    SOURCE_FILES "${cython_sources}"
*** cugraph/python/cugraph/cugraph/layour/CMakeLists.txt.orig        2024-03-27 21:25:13.589826973 +0900
--- cugraph/python/cugraph/cugraph/layout/CMakeLists.txt     2024-03-27 21:26:06.700790477 +0900
***************
*** 14,19 ****
--- 14,20 ----
  
  set(cython_sources force_atlas2_wrapper.pyx)
  set(linked_libraries cugraph::cugraph)
+ add_compile_definitions(LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE)
  rapids_cython_create_modules(
    CXX
    SOURCE_FILES "${cython_sources}"*** cugraph/python/cugraph/cugraph/linear_assignment/CMakeLists.txt.orig        2024-03-27 21:25:13.589826973 +0900
--- cugraph/python/cugraph/cugraph/linear_assignment/CMakeLists.txt     2024-03-27 21:26:06.700790477 +0900
***************
*** 14,19 ****
--- 14,20 ----
  
  set(cython_sources lap_wrapper.pyx)
  set(linked_libraries cugraph::cugraph)
+ add_compile_definitions(LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE)
  rapids_cython_create_modules(
    CXX
    SOURCE_FILES "${cython_sources}"
*** cugraph/python/cugraph/cugraph/tree/CMakeLists.txt.orig        2024-03-27 21:25:13.589826973 +0900
--- cugraph/python/cugraph/cugraph/tree/CMakeLists.txt     2024-03-27 21:26:06.700790477 +0900
***************
*** 14,19 ****
--- 14,20 ----
  
  set(cython_sources minimum_spanning_tree_wrapper.pyx)
  set(linked_libraries cugraph::cugraph)
+ add_compile_definitions(LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE)
  rapids_cython_create_modules(
    CXX
    SOURCE_FILES "${cython_sources}"
*** cugraph/python/cugraph/cugraph/components/CMakeLists.txt.orig        2024-03-27 21:25:13.589826973 +0900
--- cugraph/python/cugraph/cugraph/components/CMakeLists.txt     2024-03-27 21:26:06.700790477 +0900
***************
*** 14,19 ****
--- 14,20 ----
  
  set(cython_sources connectivity_wrapper.pyx)
  set(linked_libraries cugraph::cugraph)
+ add_compile_definitions(LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE)
  rapids_cython_create_modules(
    CXX
    SOURCE_FILES "${cython_sources}"

Minimum reproducible example

No response

Relevant log output

Refer to the following comment

Environment details

Linux 6.8.1 glibc 2.39 gcc 13.2 cuda 12.4 cmake 3.28.3

Other/Misc.

No response

Code of Conduct

  • [X] I agree to follow cuGraph's Code of Conduct
  • [X] I have searched the open bugs and have found no duplicates for this bug report

gdaisukesuzuki avatar Mar 28 '24 00:03 gdaisukesuzuki

Before applying this patch, a message like the following appeared, causing the compilation to fail. (Of course, I have set the paths for the CUDA libraries, header files, etc.)

FAILED: pylibcugraph/components/CMakeFiles/_connectivity.dir/_connectivity.cxx.o
  /usr/bin/c++ -DNO_CUGRAPH_OPS -D_connectivity_EXPORTS -isystem /usr/include/python3.11 -march=rocketlake -mtune=native -O3 -pipe -fno-plt -fexceptions        -I/opt/cuda/include         -DSPDLOG_FMT_EXTERNAL -DFMT_USE_CONSTEXPR         -Wformat -Werror=format-security         -Wp,-D_FORTIFY_SOURCE=2,-D_GLIBCXX_ASSERTIONS         -fstack-clash-protection -freport-bug -fcf-protection -O3 -DNDEBUG -fPIC -MD -MT pylibcugraph/components/CMakeFiles/_connectivity.dir/_connectivity.cxx.o -MF pylibcugraph/components/CMakeFiles/_connectivity.dir/_connectivity.cxx.o.d -o pylibcugraph/components/CMakeFiles/_connectivity.dir/_connectivity.cxx.o -c /home/dai/PKGBUILD/python-cugraph/src/cugraph/python/pylibcugraph/build/cp311-cp311-manylinux_2_39_x86_64/pylibcugraph/components/_connectivity.cxx
  In file included from /home/dai/PKGBUILD/python-cugraph/src/cugraph/python/pylibcugraph/build/cp311-cp311-manylinux_2_39_x86_64/pylibcugraph/components/_connectivity.cxx:1217:
  /usr/include/rmm/cuda_stream_view.hpp:67:30: error: ‘cuda’ has not been declared
     67 |   constexpr cuda_stream_view(cuda::stream_ref stream) noexcept : stream_{stream.get()} {}
        |                              ^~~~
  /usr/include/rmm/cuda_stream_view.hpp:67:46: error: expected ‘)’ before ‘stream’
     67 |   constexpr cuda_stream_view(cuda::stream_ref stream) noexcept : stream_{stream.get()} {}
        |                             ~                ^~~~~~~
        |                                              )
  /usr/include/rmm/cuda_stream_view.hpp:67:88: error: expected unqualified-id before ‘{’ token
     67 |   constexpr cuda_stream_view(cuda::stream_ref stream) noexcept : stream_{stream.get()} {}
        |                                                                                        ^
  /usr/include/rmm/cuda_stream_view.hpp:88:22: error: ‘cuda’ does not name a type; did you mean ‘cudaPos’?
     88 |   constexpr operator cuda::stream_ref() const noexcept { return value(); }
        |                      ^~~~
        |                      cudaPos
  In file included from /usr/include/raft/util/memory_pool-ext.hpp:18,
                   from /usr/include/raft/util/memory_pool.hpp:19,
                   from /usr/include/raft/util/cudart_utils.hpp:21,
                   from /usr/include/raft/core/interruptible.hpp:23,
                   from /usr/include/raft/core/resource/cuda_stream.hpp:18,
                   from /usr/include/raft/core/resource/cublas_handle.hpp:19,
                   from /usr/include/raft/core/device_resources.hpp:24,
                   from /usr/include/raft/core/handle.hpp:19,
                   from /home/dai/PKGBUILD/python-cugraph/src/cugraph/python/pylibcugraph/build/cp311-cp311-manylinux_2_39_x86_64/pylibcugraph/components/_connectivity.cxx:1219:
  /usr/include/rmm/mr/device/device_memory_resource.hpp:347:59: error: ‘cuda’ has not been declared
    347 |   friend void get_property(device_memory_resource const&, cuda::mr::device_accessible) noexcept {}
        |                                                           ^~~~
  /usr/include/rmm/mr/device/device_memory_resource.hpp:396:15: error: ‘cuda’ has not been declared
    396 | static_assert(cuda::mr::async_resource_with<device_memory_resource, cuda::mr::device_accessible>);
        |               ^~~~
  /usr/include/rmm/mr/device/device_memory_resource.hpp:396:67: error: expected primary-expression before ‘,’ token
    396 | static_assert(cuda::mr::async_resource_with<device_memory_resource, cuda::mr::device_accessible>);
        |                                                                   ^
  /usr/include/rmm/mr/device/device_memory_resource.hpp:396:69: error: expected string-literal before ‘cuda’
    396 | static_assert(cuda::mr::async_resource_with<device_memory_resource, cuda::mr::device_accessible>);
        |                                                                     ^~~~
  /usr/include/rmm/mr/device/device_memory_resource.hpp:396:68: error: expected ‘)’ before ‘cuda’
    396 | static_assert(cuda::mr::async_resource_with<device_memory_resource, cuda::mr::device_accessible>);
        |              ~                                                     ^~~~~
        |                                                                    )
  In file included from /usr/include/rmm/mr/device/pool_memory_resource.hpp:27,
                   from /usr/include/raft/util/memory_pool-inl.hpp:24,
                   from /usr/include/raft/util/memory_pool.hpp:22:
  /usr/include/rmm/resource_ref.hpp:32:29: error: ‘cuda’ does not name a type; did you mean ‘cudaPos’?
     32 | using device_resource_ref = cuda::mr::resource_ref<cuda::mr::device_accessible>;
        |                             ^~~~
        |                             cudaPos
....

gdaisukesuzuki avatar Mar 28 '24 06:03 gdaisukesuzuki

This looks due to an improper rmm installation. The rmm package will export the requirement ( https://github.com/rapidsai/rmm/blob/branch-24.04/CMakeLists.txt#L97 ) which will be transitively picked up by since it is a PUBLIC dependency of the cugraph::cugraph target.

It looks like you have a system installed rmm under /usr it would be good to see what the contents of rmm-targets.cmake is ( /usr/lib/cmake/rmm/ )

robertmaynard avatar Apr 01 '24 17:04 robertmaynard

@gdaisukesuzuki , have you had a chance to check your rmm installation as @robertmaynard suggested?

rlratzel avatar Apr 23 '24 16:04 rlratzel

reopen if this is still an issue.

kingmesal avatar May 29 '24 19:05 kingmesal