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

Link libcudf_kafka against cuDF CMake export targets (CPM) #7484

Closed
wants to merge 36 commits into from

Conversation

jdye64
Copy link
Contributor

@jdye64 jdye64 commented Mar 2, 2021

Now that #7107 is merged libcudf_kafka needs to link against those newly exposed cudf::cudf and rmm::rmm targets otherwise the build fails.

@jdye64 jdye64 requested a review from a team as a code owner March 2, 2021 16:22
@github-actions github-actions bot added CMake CMake build issue libcudf Affects libcudf (C++/CUDA) code. labels Mar 2, 2021
@jdye64 jdye64 marked this pull request as draft March 2, 2021 16:23
cpp/libcudf_kafka/CMakeLists.txt Outdated Show resolved Hide resolved
cpp/libcudf_kafka/CMakeLists.txt Outdated Show resolved Hide resolved
@trxcllnt trxcllnt added non-breaking Non-breaking change 2 - In Progress Currently a work in progress code quality Java Affects Java cuDF API. improvement Improvement / enhancement to an existing function labels Mar 2, 2021
@jdye64 jdye64 force-pushed the link_against_cpm_exports branch from cdce3e2 to beaf86e Compare March 2, 2021 17:10
@github-actions github-actions bot added gpuCI and removed Java Affects Java cuDF API. labels Mar 2, 2021
docs/cudf/source/conf.py Outdated Show resolved Hide resolved
@jdye64
Copy link
Contributor Author

jdye64 commented Mar 5, 2021

rerun tests

@trxcllnt
Copy link
Contributor

trxcllnt commented Mar 19, 2021

Seems like CPM is still building libcudf, even though it's installed:

-- CPM: adding package [email protected] (branch-0.19)

Is this line why find_package(cudf) is failing to find libcudf?

-- Unable to find cuda_runtime.h in "/jenkins/workspace/rapidsai/gpuci/cudf/prb/cudf-cpu-cuda-build/CUDA/include" for CUDAToolkit_INCLUDE_DIR.

Unrelated, but should these all have -real after them? I thought just the last one should?

-- CUDF: Building CUDF for GPU architectures: 60-real;70-real;75-real;80

@jdye64
Copy link
Contributor Author

jdye64 commented Mar 19, 2021 via email

@trxcllnt
Copy link
Contributor

Yeah, I'm seeing this in CI for my cuSpatial PR as well. I just finished downloading the nightly image that should have cuDF in conda, will investigate why CPM can't seem to find libcudf.

@robertmaynard
Copy link
Contributor

-- CUDF: Building CUDF for GPU architectures: 60-real;70-real;75-real;80

That is correct. -real means just generate for that architecture ( SASS ), while 80 means generate SASS and PTX.

@trxcllnt trxcllnt mentioned this pull request Mar 19, 2021
rapids-bot bot pushed a commit that referenced this pull request Mar 20, 2021
This PR makes `find_package(cudf)` work when `libcudf` is installed via conda.

This should make CPM use the conda-installed `libcudf` in #7484 and rapidsai/cuspatial#365.

Tested in a `gpuci/miniconda-cuda:10.2-devel-ubuntu18.04` container.

Install dependencies:
```
mamba install -n base \
 -c conda-forge gtest gmock cmake=3.18 boost-cpp=1.72.0 \
 -c rapidsai-nightly libcudf
```

Use this `CMakeLists.txt`:
```cmake
cmake_minimum_required(VERSION 3.18)
project(test VERSION 1.0.0 LANGUAGES C CXX CUDA)
find_package(cudf)
add_library(test test.cpp)
target_link_libraries(test cudf::cudf)
```

<details><summary>See this output:</summary><pre>
(base) root@8c350dfb37f1:/tmp/findpackagecudf# mkdir build && cmake -B build -S .
-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- The CUDA compiler identification is NVIDIA 10.2.89
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting CUDA compiler ABI info
-- Detecting CUDA compiler ABI info - done
-- Check for working CUDA compiler: /usr/local/cuda/bin/nvcc - skipped
-- Detecting CUDA compile features
-- Detecting CUDA compile features - done
-- Found CUDAToolkit: /usr/local/cuda/include (found version "10.2.89") 
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Found ZLIB: /opt/conda/lib/libz.so (found version "1.2.11") 
-- Found Boost: /opt/conda/include (found suitable version "1.72.0", minimum required is "1.65.0") found components: filesystem 
-- Found Thrust: /usr/local/cuda/include (found suitable version "1.9.7", minimum required is "1.9.0") 
-- Found rmm: /opt/conda/lib/cmake/rmm/rmm-config.cmake (found suitable version "0.19.0", minimum required is "0.19") 
-- Found GTest: /opt/conda/lib/libgtest.so (Required is at least version "1.10.0") 
-- Found Thrust: /opt/conda/include/libcudf/Thrust/thrust/cmake/thrust-config.cmake (found suitable version "1.10.0.0", minimum required is "1.10.0") 
-- Found cudf: /opt/conda/lib/cmake/cudf/cudf-config.cmake (found version "0.19.0") 
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/findpackagecudf/build
</pre></details>

<details><summary>The generated compile command for test.cpp:</summary><pre>
/usr/bin/c++
 -DBOOST_NO_CXX14_CONSTEXPR
 -DCUDF_VERSION=0.19.0
 -DJITIFY_USE_CACHE
 -DSPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_INFO
 -DTHRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_CUDA
 -DTHRUST_HOST_SYSTEM=THRUST_HOST_SYSTEM_CPP
 -I/opt/conda/include/libcudf/Thrust/dependencies/cub
 -isystem /opt/conda/include
 -isystem /opt/conda/include/libcudf/libcudacxx
 -isystem /opt/conda/include/libcudf/Thrust
 -isystem /usr/local/cuda/include
 -fPIC
 -o CMakeFiles/test.dir/test.cpp.o
 -c /tmp/findpackagecudf/test.cpp
</pre></details>

Authors:
  - Paul Taylor (@trxcllnt)

Approvers:
  - Keith Kraus (@kkraus14)

URL: #7658
@kkraus14
Copy link
Collaborator

rerun tests

1 similar comment
@trxcllnt
Copy link
Contributor

rerun tests

@jdye64
Copy link
Contributor Author

jdye64 commented Mar 22, 2021

hmm seeing some odd errors about RMM? Any ideas @trxcllnt ?

  Attempt to promote imported target "rmm::rmm" to global scope (by setting
  IMPORTED_GLOBAL) which is not built in this directory.
Call Stack (most recent call first):
  build/_deps/cudf-src/cpp/cmake/thirdparty/CUDF_GetRMM.cmake:52 (fix_cmake_global_defaults)
  build/_deps/cudf-src/cpp/cmake/thirdparty/CUDF_GetRMM.cmake:62 (find_and_configure_rmm)
  build/_deps/cudf-src/cpp/CMakeLists.txt:131 (include)```

@robertmaynard
Copy link
Contributor

hmm seeing some odd errors about RMM? Any ideas @trxcllnt ?

  Attempt to promote imported target "rmm::rmm" to global scope (by setting
  IMPORTED_GLOBAL) which is not built in this directory.
Call Stack (most recent call first):
  build/_deps/cudf-src/cpp/cmake/thirdparty/CUDF_GetRMM.cmake:52 (fix_cmake_global_defaults)
  build/_deps/cudf-src/cpp/cmake/thirdparty/CUDF_GetRMM.cmake:62 (find_and_configure_rmm)
  build/_deps/cudf-src/cpp/CMakeLists.txt:131 (include)```

I wonder if the problem is that the rmm::rmm target exists before we start to include cudf, and we try to add it again and the GLOBAL import logic inside find_and_configure_rmm fails.

Might just want to early terminate find_and_configure_rmm if the rmm::rmm target already exists.

@jdye64
Copy link
Contributor Author

jdye64 commented Mar 22, 2021 via email

@robertmaynard
Copy link
Contributor

I’m not very familiar with that part of the code base. Care to show me what that snippet might look like and I could just add it to this PR and see what happens. If it works can just be part of this PR

Try this change ( https://github.com/rapidsai/cudf/blob/branch-0.19/cpp/cmake/thirdparty/CUDF_GetRMM.cmake )

function(find_and_configure_rmm VERSION)
    if(TARGET rmm::rmm)
        return()
    endif

@jdye64
Copy link
Contributor Author

jdye64 commented Mar 22, 2021

Ok, that fixed the RMM issue. Now I'm seeing this

Could NOT find cuFile (missing: cuFile_LIBRARY cuFileRDMA_LIBRARY)

any ideas there?

@jdye64
Copy link
Contributor Author

jdye64 commented Mar 22, 2021

Ok, that fixed the RMM issue. Now I'm seeing this

Could NOT find cuFile (missing: cuFile_LIBRARY cuFileRDMA_LIBRARY)

any ideas there?

Oops, no, actually its still the RMM error. https://gpuci.gpuopenanalytics.com/job/rapidsai/job/gpuci/job/cudf/job/prb/job/cudf-cpu-cuda-build/CUDA=11.0/1720/consoleText

@kkraus14
Copy link
Collaborator

-- CUDF: Building CUDF for GPU architectures: 52

Something else is off here as well.

@robertmaynard
Copy link
Contributor

Ok, that fixed the RMM issue. Now I'm seeing this
Could NOT find cuFile (missing: cuFile_LIBRARY cuFileRDMA_LIBRARY)
any ideas there?

Oops, no, actually its still the RMM error. https://gpuci.gpuopenanalytics.com/job/rapidsai/job/gpuci/job/cudf/job/prb/job/cudf-cpu-cuda-build/CUDA=11.0/1720/consoleText

That failure looks to be coming from cudf to me:

-- CPM: adding package [email protected] (cudf_0.16)
-- CPM: adding package [email protected] (1.10.0)
-- CPM: using local package [email protected]
-- CPM: using local package [email protected]
-- CPM: adding package [email protected] (1.4.0)
-- CPM: using local package [email protected]
-- Could NOT find cuFile (missing: cuFile_LIBRARY cuFileRDMA_LIBRARY) 
-- Configuring done

Looks like it found the system installed rmm and failed a couple steps after that when looking cuFile.

@kkraus14
Copy link
Collaborator

Looks like it found the system installed rmm and failed a couple steps after that when looking cuFile.

That's an optional dependency so it shouldn't be an issue.

I think the error is this:

CMake Error at build/_deps/cudf-src/cpp/cmake/thirdparty/CUDF_GetCPM.cmake:27 (set_target_properties):
  Attempt to promote imported target "rmm::rmm" to global scope (by setting
  IMPORTED_GLOBAL) which is not built in this directory.
Call Stack (most recent call first):
  build/_deps/cudf-src/cpp/cmake/thirdparty/CUDF_GetRMM.cmake:52 (fix_cmake_global_defaults)
  build/_deps/cudf-src/cpp/cmake/thirdparty/CUDF_GetRMM.cmake:62 (find_and_configure_rmm)
  build/_deps/cudf-src/cpp/CMakeLists.txt:131 (include)

@robertmaynard
Copy link
Contributor

Looks like it found the system installed rmm and failed a couple steps after that when looking cuFile.

That's an optional dependency so it shouldn't be an issue.

I think the error is this:

CMake Error at build/_deps/cudf-src/cpp/cmake/thirdparty/CUDF_GetCPM.cmake:27 (set_target_properties):
  Attempt to promote imported target "rmm::rmm" to global scope (by setting
  IMPORTED_GLOBAL) which is not built in this directory.
Call Stack (most recent call first):
  build/_deps/cudf-src/cpp/cmake/thirdparty/CUDF_GetRMM.cmake:52 (fix_cmake_global_defaults)
  build/_deps/cudf-src/cpp/cmake/thirdparty/CUDF_GetRMM.cmake:62 (find_and_configure_rmm)
  build/_deps/cudf-src/cpp/CMakeLists.txt:131 (include)

Okay I see that error now, but I see that it is happening before compiler detection which is not expected.
What is causing this invocation of CMake? And with what parameters?

@kkraus14
Copy link
Collaborator

Comment on lines +32 to +36
# * find CUDAToolkit package
# * determine GPU architectures
# * enable the CMake CUDA language
# * set other CUDA compilation flags
include(../cmake/Modules/ConfigureCUDA.cmake)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is causing problems. There's no device code / actual cuda configuration needed for libcudf, and we're doing this before importing cudf / rmm / etc. which causes the CUDA language to be enabled which breaks things I think?

Copy link
Contributor

Choose a reason for hiding this comment

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

In my dummy CMakeLists.txt for #7658, CUDA had to be enabled for the find_package(cudf) to succeed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, that would make sense actually since I removed CUDA in a previous commit. Both @kkraus14 and I were both under the impression it was not needed since libcudf_kafka doesn't use CUDA explicitly. Are you saying I need to add it back?

Copy link
Collaborator

Choose a reason for hiding this comment

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

My thought is that if someone needs to enable CUDA before doing find_package(cudf), we have something broken in our cudf cmake config.

Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like cuftestutil and cudf both have some CUDA information in the export information. That would require downstream consumers to enable CUDA.

  • cuftestutil is tricky as it is a static library with CUDA sources, so CMake needs to export that when linking downstream it has CUDA dependencies ( so you need to enable the language )
  • cudf is leaking via compile flags, would could be fixed

Copy link
Contributor

Choose a reason for hiding this comment

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

Both of these should be resolved by having cudf-config.cmake have ( enable_language(CUDA) ) in the short term while we sort out the above two issues.

rapids-bot bot pushed a commit that referenced this pull request Mar 25, 2021
This integrates the changes from #7484 plus others required to get
`cudf_kafka` to build cleanly after the CMake refactoring of `cudf`

Authors:
  - Robert Maynard (@robertmaynard)
  - Jeremy Dyer (@jdye64)

Approvers:
  - Mike Wendt (@mike-wendt)
  - Keith Kraus (@kkraus14)

URL: #7674
@robertmaynard
Copy link
Contributor

I think this can be closed now that #7674 has been merged.

@kkraus14 kkraus14 closed this Mar 25, 2021
@jdye64 jdye64 deleted the link_against_cpm_exports branch April 25, 2021 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2 - In Progress Currently a work in progress CMake CMake build issue improvement Improvement / enhancement to an existing function libcudf Affects libcudf (C++/CUDA) code. non-breaking Non-breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants