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]: cub/detail/detect_cuda_runtime.cuh should not include cuda_runtime_api.h when compiled by NVRTC #2095

Closed
1 task done
leofang opened this issue Jul 29, 2024 · 1 comment
Labels
bug Something isn't working right.

Comments

@leofang
Copy link
Member

leofang commented Jul 29, 2024

Is this a duplicate?

Type of Bug

Compile-time Error

Component

CUB

Describe the bug

CuPy is in the process of reducing its Jitify usage to reduce JIT overhead and moving closer to CCCL head (cupy/cupy#8412), and this long-time issue gets exposed.

The header cuda_runtime_api.h is currently included unconditionally by CUB:

#include <cuda_runtime_api.h>

However it should not be. In Python it is possible that CUB & CuPy are deployed without the presence of the full set of CUDA headers (since they are not redistributable), and so when JIT'ing CUB headers using NVRTC a compile-time "file not found" error would be raised.

With Jitify, it defaults to commenting out headers that are not found and retrying the compilation, therefore this issue has been guarded for a long time until now.

How to Reproduce

n/a

Expected behavior

Mimicking Jitify behavior and making the CUDA headers optional for NVRTC.

Reproduction link

No response

Operating System

No response

nvidia-smi output

No response

NVCC version

No response

@leofang leofang added the bug Something isn't working right. label Jul 29, 2024
@leofang
Copy link
Member Author

leofang commented Jul 29, 2024

FYI this simple patch did the job for CuPy:

diff --git a/cub/cub/detail/detect_cuda_runtime.cuh b/cub/cub/detail/detect_cuda_runtime.cuh
index 44ee81119..2c2398b56 100644
--- a/cub/cub/detail/detect_cuda_runtime.cuh
+++ b/cub/cub/detail/detect_cuda_runtime.cuh
@@ -44,7 +44,10 @@
 #  pragma system_header
 #endif // no system header
 
+// CUDA headers might not be present when using NVRTC, see NVIDIA/cccl#2095 for detail
+#ifndef __CUDACC_RTC__
 #include <cuda_runtime_api.h>
+#endif
 
 #ifdef DOXYGEN_SHOULD_SKIP_THIS // Only parse this during doxygen passes:
 

miscco added a commit to miscco/cccl that referenced this issue Jul 30, 2024
This may fail as discussed in NVIDIA#2095

Fixes 2095
miscco added a commit to miscco/cccl that referenced this issue Jul 30, 2024
This may fail as discussed in NVIDIA#2095

Fixes 2095
miscco added a commit that referenced this issue Jul 30, 2024
This may fail as discussed in #2095

Fixes 2095
@miscco miscco closed this as completed Jul 30, 2024
pciolkosz pushed a commit to pciolkosz/cccl that referenced this issue Aug 4, 2024
pciolkosz pushed a commit to pciolkosz/cccl that referenced this issue Aug 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working right.
Projects
Archived in project
Development

No branches or pull requests

2 participants