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

[FIX] Get libcudacxx from cuco #632

Merged

Conversation

trxcllnt
Copy link
Collaborator

@trxcllnt trxcllnt commented Apr 27, 2022

This PR fixes a CMake configuration failure when using RAFT's build dir as the package root, e.g.:

cmake -S /cuml/cpp -B /cuml/cpp/build -Draft_ROOT=/raft/cpp/build

CMake fails with this mysterious error:

  The link interface of target "raft::raft" contains:

    std::mdspan

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.

However the problem isn't mdspan.

The error occurs when raft-dependencies.cmake tries and fails to find libcudacxx:
raft/cpp/build/release/raft-dependencies.cmake(206):  find_dependency(libcudacxx )
conda/cuda_11.6/envs/rapids/share/cmake-3.23/Modules/CMakeFindDependencyMacro.cmake(34):  set(cmake_fd_quiet_arg )
conda/cuda_11.6/envs/rapids/share/cmake-3.23/Modules/CMakeFindDependencyMacro.cmake(35):  if(raft_FIND_QUIETLY )
conda/cuda_11.6/envs/rapids/share/cmake-3.23/Modules/CMakeFindDependencyMacro.cmake(36):  set(cmake_fd_quiet_arg QUIET )
conda/cuda_11.6/envs/rapids/share/cmake-3.23/Modules/CMakeFindDependencyMacro.cmake(38):  set(cmake_fd_required_arg )
conda/cuda_11.6/envs/rapids/share/cmake-3.23/Modules/CMakeFindDependencyMacro.cmake(39):  if(raft_FIND_REQUIRED )
conda/cuda_11.6/envs/rapids/share/cmake-3.23/Modules/CMakeFindDependencyMacro.cmake(43):  get_property(cmake_fd_alreadyTransitive GLOBAL PROPERTY _CMAKE_libcudacxx_TRANSITIVE_DEPENDENCY )
conda/cuda_11.6/envs/rapids/share/cmake-3.23/Modules/CMakeFindDependencyMacro.cmake(47):  find_package(libcudacxx  QUIET  )
CMake Debug Log at conda/cuda_11.6/envs/rapids/share/cmake-3.23/Modules/CMakeFindDependencyMacro.cmake:47 (find_package):
  find_package considered the following paths for Findlibcudacxx.cmake:
cuml/cpp/build/cuda-11.6.0/branch-22.06/release/CPM_modules/Findlibcudacxx.cmake cuml/cpp/build/cuda-11.6.0/branch-22.06/release/_deps/rapids-cmake-src/rapids-cmake/Findlibcudacxx.cmake conda/cuda_11.6/envs/rapids/share/cmake-3.23/Modules/Findlibcudacxx.cmake
The file was not found.
_ROOT CMake variable [CMAKE_FIND_USE_PACKAGE_ROOT_PATH].
raft/cpp/build/release
CMAKE_PREFIX_PATH variable [CMAKE_FIND_USE_CMAKE_PATH].
conda/cuda_11.6/envs/rapids
CMAKE_FRAMEWORK_PATH and CMAKE_APPBUNDLE_PATH variables [CMAKE_FIND_USE_CMAKE_PATH].
Env variable libcudacxx_DIR [CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH].
none
CMAKE_PREFIX_PATH env variable [CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH].
none
CMAKE_FRAMEWORK_PATH and CMAKE_APPBUNDLE_PATH env variables [CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH].
none
Paths specified by the find_package HINTS option.
none
Standard system environment variables [CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH].
conda/cuda_11.6 /usr/local /usr / /usr/local/cuda
CMake User Package Registry [CMAKE_FIND_USE_PACKAGE_REGISTRY].
none
CMake variables defined in the Platform file [CMAKE_FIND_USE_CMAKE_SYSTEM_PATH].
/usr/X11R6 /usr/pkg /opt
CMake System Package Registry [CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY].
none
Paths specified by the find_package PATHS option.
none
find_package considered the following locations for libcudacxx's Config module:
raft/cpp/build/release/libcudacxxConfig.cmake raft/cpp/build/release/libcudacxx-config.cmake raft/cpp/build/release/cmake/libcudacxxConfig.cmake raft/cpp/build/release/cmake/libcudacxx-config.cmake conda/cuda_11.6/envs/rapids/libcudacxxConfig.cmake conda/cuda_11.6/envs/rapids/libcudacxx-config.cmake conda/cuda_11.6/libcudacxxConfig.cmake conda/cuda_11.6/libcudacxx-config.cmake /usr/local/libcudacxxConfig.cmake /usr/local/libcudacxx-config.cmake /usr/libcudacxxConfig.cmake /usr/libcudacxx-config.cmake /libcudacxxConfig.cmake /libcudacxx-config.cmake /usr/local/cuda/libcudacxxConfig.cmake /usr/local/cuda/libcudacxx-config.cmake /opt/libcudacxxConfig.cmake /opt/libcudacxx-config.cmake
The file was not found.
Call Stack (most recent call first): raft/cpp/build/release/raft-dependencies.cmake:206 (find_dependency) raft/cpp/build/release/raft-config.cmake:85 (include) build/cuda-11.6.0/branch-22.06/release/cmake/CPM_0.35.0.cmake:215 (find_package) build/cuda-11.6.0/branch-22.06/release/cmake/CPM_0.35.0.cmake:272 (cpm_find_package) build/cuda-11.6.0/branch-22.06/release/_deps/rapids-cmake-src/rapids-cmake/cpm/find.cmake:152 (CPMFindPackage) cmake/thirdparty/get_raft.cmake:50 (rapids_cpm_find) cmake/thirdparty/get_raft.cmake:80 (find_and_configure_raft) CMakeLists.txt:200 (include)

The cause of the failure is this:

  1. RAFT's CMakeLists.txt adds cuco before adding libcudacxx (here)
  2. cuco is added to the raft-distance-exports export set (here)
    • cuco adds libcudacxx, because it was declared before libcudacxx in step 1:
    -- CPM: cuco: adding package libcudacxx@1.7.0 (1.7.0)
    
  3. libcudacxx is added to the raft-exports export set (here)
    • Since libcudacxx has already been added by cuco in step 2, a find_dependency(libcudacxx) call (not a CPMFindPackage call) is recorded in raft-dependencies.cmake

When someone uses the raft build dir as the package root, CMake runs raft-dependencies.cmake before raft-distance-dependencies.cmake. raft-dependencies.cmake fails at find_dependency(libcudacxx), because the CPMFindPackage("NAME;cuco;...) call that is expected to introduce libcudacxx hasn't been executed yet.

Alternative fix

There are two other possible fixes aside from the one in this PR:

  1. Swap the order of these two lines in CMakeLists.txt.
  2. Change the libcudacxx BUILD_EXPORT_SET and INSTALL_EXPORT_SET to raft-distance-exports so find_dependency(libcudacxx) is recorded in raft-distance-dependencies.cmake after cuco (and cuco's libcudacxx dependency) has been found.

I didn't see any references to <cuda/std/...> in RAFT itself, so the cleanest option is to delete RAFT's get_libcudacxx.cmake.

@trxcllnt trxcllnt requested a review from a team as a code owner April 27, 2022 18:10
@trxcllnt trxcllnt requested a review from cjnolet April 27, 2022 18:10
@robertmaynard robertmaynard added bug Something isn't working 3 - Ready for Review non-breaking Non-breaking change labels Apr 27, 2022
Copy link
Contributor

@robertmaynard robertmaynard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't see any references to <cuda/std/...> in RAFT itself, so the cleanest option is to delete RAFT's get_libcudacxx.cmake, since it doesn't seem to be needed.

I also can't see any <cuda/std/> includes so I agree that this simplification is the best approach.

@cjnolet
Copy link
Member

cjnolet commented Apr 27, 2022

rerun tests

@cjnolet
Copy link
Member

cjnolet commented Apr 27, 2022

@gpucibot merge

@rapids-bot rapids-bot bot merged commit fa89c37 into rapidsai:branch-22.06 Apr 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 - Ready for Review bug Something isn't working CMake cpp non-breaking Non-breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants