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

[BUG] No way to set RMM_LOGGING_LEVEL when building Python module #1336

Closed
harrism opened this issue Sep 7, 2023 · 3 comments · Fixed by #1339
Closed

[BUG] No way to set RMM_LOGGING_LEVEL when building Python module #1336

harrism opened this issue Sep 7, 2023 · 3 comments · Fixed by #1339
Assignees
Labels
bug Something isn't working CMake

Comments

@harrism
Copy link
Member

harrism commented Sep 7, 2023

Describe the bug
When building the RMM Python module, passing -DRMM_LOGGING_LEVEL=TRACE or -DSPDLOG_ACTIVE_LEVEL=SPDLOG_ACTIVE_LEVEL_TRACE to the cmake configuration does not change the SPDLOG_ACTIVE_LEVEL that is active when RMM C++ code is compiled, and so it is always at SPDLOG_ACTIVE_LEVEL_INFO.

Steps/Code to reproduce bug
In the RMM dev container, run build-rmm-python -DRMM_LOGGING_LEVEL=TRACE -DSPDLOG_ACTIVE_LEVEL=SPDLOG_ACTIVE_LEVEL_TRACE.

This has no effect on logging.

Expected behavior
All RMM_LOG_TRACE message should be printed to a file rmm_log.txt in the current directory when this is run.

Environment details (please complete the following information):

  • Environment location: Lab DGX
  • Method of RMM install: RMM dev container

Additional context
Add any other context about the problem here.

@harrism harrism added bug Something isn't working CMake ? - Needs Triage Need team to review and classify labels Sep 7, 2023
@vyasr
Copy link
Contributor

vyasr commented Sep 11, 2023

Copying my message from Slack:

I'm not sure that this is something CMake is designed to support. If I configure a project with target_compile_definitions(X PUBLIC Y), that's indicating that anything compiling against this project needs to have that defined, just as with setting target_include_directories or target_link_libraries. In the case of header-only libraries I could see an argument why you might expect it to be overridable since there's no compilation, but OTOH it's not a generally well-defined behavior for the case where you have compiled components and I wouldn't expect CMake to specialize for that.

You could always make this work by having the C++ library configured by the Python library, e.g. by setting -DFIND_RMM_CPP=OFF. That's not a general solution because you don't want to do that for compiled libraries like libcudf (otherwise you'd recompile libcudf when building cudf Python) but it would work for this specific case (rmm, which is header-only).

One alternative here would be for the C++ CMake in rmm to set one macro that is the "default" logging level but then support a second macro that would override it. Then consumers of the headers would be able to override the logger, but the C++ library would have a default level. Again, this only really makes sense because of the header-only nature of the library.

Looks like there's an open CMake issue where one of the devs comes to a similar conclusion: https://gitlab.kitware.com/cmake/cmake/-/issues/24099

@harrism
Copy link
Member Author

harrism commented Sep 12, 2023

I don't see why this isn't doable. The RMM C++ cmakelists only creates a property with defined values, and a default. It never sets any compile definitions based on it. I found that this is working for Cython, but realized that SPDLOG requires both a compile-time definition and a run-time call to set the level on the logger object. So I created a PR to expose this via the RMM Python API.

@harrism harrism moved this from Todo to In Progress in RMM Project Board Sep 12, 2023
@harrism harrism moved this from In Progress to Review in RMM Project Board Sep 12, 2023
@harrism harrism removed the ? - Needs Triage Need team to review and classify label Sep 12, 2023
@harrism harrism self-assigned this Sep 12, 2023
@harrism harrism moved this from Todo to Review in RMM Project Board Sep 20, 2023
@vyasr
Copy link
Contributor

vyasr commented Sep 20, 2023

We discussed this offline, Mark is correct. I had assumed in conversation that the C++ CMakeLists.txt was actually setting compile definitions, which is not the case.

rapids-bot bot pushed a commit that referenced this issue Sep 26, 2023
Enables RMM debug logging in Python and exposes controls for the level of logging. Fixes #1336.

Authors:
  - Mark Harris (https://github.com/harrism)
  - Lawrence Mitchell (https://github.com/wence-)

Approvers:
  - Lawrence Mitchell (https://github.com/wence-)
  - Vyas Ramasubramani (https://github.com/vyasr)

URL: #1339
@github-project-automation github-project-automation bot moved this from Review to Done in RMM Project Board Sep 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working CMake
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants