[BUG]: namespace "std" has no member "is_same_v" #643
Answered
by
leofang
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 Reproducedef get_include_dir_cuda() -> Path:
"""Best-effort guess of the Toolkit’s <cuda>/include directory."""
import os, shutil
if os.getenv("CUDA_HOME"):
return Path(os.environ["CUDA_HOME"]) / "include"
# fall back to the directory that owns nvcc (works for most local installs)
nvcc = shutil.which("nvcc")
if nvcc:
return Path(nvcc).parent.parent / "include"
raise RuntimeError("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}" for i in dev.compute_capability)
print(f'arch:{arch}')
print(get_include_dir_cuda())
# Compile cuda to ptx
module_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
|
Beta Was this translation helpful? Give feedback.
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 |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
capybara-club
Sign up for free
to 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).