Uh oh!
There was an error while loading. Please reload this page.
[BUG]: namespace "std" has no member "is_same_v" #643
Answered
byleofang
capybara-club
asked this question in
Q&A
Is this a duplicate?
Type of BugCompile-time Error Componentcuda.core Describe the bugI can't seem to get code like std::is_same_v<T, f32>to compile. I tried adding Any ideas? How to Reproducedefget_include_dir_cuda() ->Path:
"""Best-effort guess of the Toolkit’s <cuda>/include directory."""importos, shutilifos.getenv("CUDA_HOME"):
returnPath(os.environ["CUDA_HOME"]) /"include"# fall back to the directory that owns nvcc (works for most local installs)nvcc=shutil.which("nvcc")
ifnvcc:
returnPath(nvcc).parent.parent/"include"raiseRuntimeError("Cannot find CUDA include directory")
code=r""" #include <cuda/std/type_traits> extern "C" __global__ void hello() { static_assert(std::is_same_v<float, float>); printf("hello from device\n"); } """dev=Device()
dev.set_current()
s=dev.create_stream()
arch="".join(f"{i}"foriindev.compute_capability)
print(f'arch:{arch}')
print(get_include_dir_cuda())
# Compile cuda to ptxmodule_ptx= \
Program(
code, code_type="c++", options= \
ProgramOptions(
std="c++17", arch=f"sm_{arch}",
include_path=[get_include_dir_cuda()]
)
).compile("ptx", logs=sys.stdout)
print(module_ptx.code.decode())Expected behaviorShould compile. Operating SystemUbuntu 24.04 nvidia-smi output |
Answered by
leofang
May 18, 2025
Replies: 1 comment 1 reply
Hi @capybara-club, to use libcudacxx (libcu++) headers we need to use fully qualified names |
1 reply
Answer selected bycapybara-club
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @capybara-club, to use libcudacxx (libcu++) headers we need to use fully qualified names
cuda::std::is_same_v. The standard C++ names are not visible to the CUDA online compiler (NVRTC).