-
-
Notifications
You must be signed in to change notification settings - Fork 87
Open
Labels
Description
Description
When compiling a .cu file with CUDA 12, using cuda-api-wrappers together with Thrust leads to cuda::span redefinition and ambiguous constructor errors. The same code compiles fine under CUDA 11.
Minimal Reproducer
#include <cuda/api.hpp> // Must come first to trigger the error
#include <thrust/device_vector.h>
#include <thrust/execution_policy.h>
void trigger() { cuda::span<float> s{nullptr, 0}; }
int main() {
trigger();
return 0;
}Compile with:
nvcc -x cu -std=c++20 -arch=sm_75 -cudart shared \
-I <path-to-cuda-api-wrappers> \
-I <CUDA-include-path> \
-c main.cpp -o main.obj
Observed Behavior
Errors like:
error C2977: 'cuda::span': too many template arguments
error C2641: cannot deduce template arguments for 'cuda::span'
error C2780: expects 0 arguments - 2 provided
Notes
- The issue only appears when compiling the file as a CUDA source (-x cu) in CUDA 12.
- Treated as a normal C++ file, the code compiles fine.
- Likely related to changes in CUDA 12 handling of cuda::span and C++20 aggregate initialization.
Reactions are currently unavailable