Skip to content

[BUG]: namespace "std" has no member "is_same_v" #641

@capybara-club

Description

@capybara-club

Is this a duplicate?

Type of Bug

Compile-time Error

Component

cuda.core

Describe the bug

I can't seem to get code like

std::is_same_v<T, f32>

to compile. I tried adding #include <cuda/std/type_traits> and that didn't fix it. I have c++17 set.

Any ideas?

How to Reproduce

def 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 behavior

Should compile.

Operating System

Ubuntu 24.04

nvidia-smi output

+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 575.55.01              Driver Version: 576.40         CUDA Version: 12.9     |
|-----------------------------------------+------------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id          Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
|                                         |                        |               MIG M. |
|=========================================+========================+======================|
|   0  NVIDIA GeForce RTX 4090        On  |   00000000:01:00.0  On |                  Off |
|  0%   45C    P3             63W /  450W |    2111MiB /  24564MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+

+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI              PID   Type   Process name                        GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|  No running processes found                                                             |
+-----------------------------------------------------------------------------------------+

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions