Skip to content

Windows CUDA Build Failure: Ambiguous std in cuda_vectorized_test.cu (CUDA 12.6/MSVC 2019) #152291

@jifferyfeng

Description

@jifferyfeng

🐛 Describe the bug

When building PyTorch from source on Windows, the compilation fails with the following error in cuda_vectorized_test.cu:

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xtree(1394): error C2872: “std”: ambiguous symbol

Error Context:
The issue occurs during the compilation of cuda_vectorized_test.cu with NVCC (CUDA 12.6). The error suggests a namespace conflict with std, where the compiler cannot resolve whether std refers to the standard library or another definition (possibly from C10/cuda/CUDAStream.h).

Affected Components:

File: aten/src/ATen/test/cuda_vectorized_test.cu

Related Headers:

C10/cuda/CUDAStream.h

Google Test headers (gtest/internal/gtest-internal.h)

MSVC STL headers (xtree, map)

Build Environment:

OS: Windows

CUDA: v12.6

MSVC: 2019 Community (v14.29.30133)

PyTorch Commit: Likely recent (from source checkout)

Error logs

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xtree(1394): error C2872: “std”:

C:/pytorch\c10/cuda/CUDAStream.h(261): note: may be “std”

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xtree(1394): note: or “std”

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xtree(1391): note: “unsigned __int64 std::_Tree<std::_Tmap_traits<_Kty,_Ty,_Pr,_Alloc,false>>::count(const std::basic_string<char,std::char_traits,std::allocator> &) const”
with
[
_Kty=std::basic_string<char,std::char_traits,std::allocator>,
_Ty=testing::internal::CodeLocation,
_Pr=std::less,
_Alloc=std::allocator<std::pair<const std::basic_string<char,std::char_traits,std::allocator>,testing::internal::CodeLocation>>
]

C:/pytorch/cmake/../third_party/googletest/googletest/include\gtest/internal/gtest-internal.h(603): note: “unsigned __int64 std::_Tree<std::_Tmap_traits<_Kty,_Ty,_Pr,_Alloc,false>>::count(const std::basic_string<char,std::char_traits,std::allocator> &) const”
with
[
_Kty=std::basic_string<char,std::char_traits,std::allocator>,
_Ty=testing::internal::CodeLocation,
_Pr=std::less,
_Alloc=std::allocator<std::pair<const std::basic_string<char,std::char_traits,std::allocator>,testing::internal::CodeLocation>>
]

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\map(73): note: “std::_Tree<std::_Tmap_traits<_Kty,_Ty,_Pr,_Alloc,false>>”
with
[
_Kty=std::basic_string<char,std::char_traits,std::allocator>,
_Ty=testing::internal::CodeLocation,
_Pr=std::less,
_Alloc=std::allocator<std::pair<const std::basic_string<char,std::char_traits,std::allocator>,testing::internal::CodeLocation>>
]

C:/pytorch/cmake/../third_party/googletest/googletest/include\gtest/internal/gtest-internal.h(623): note: “std::map<std::basic_string<char,std::char_traits,std::allocator>,testing::internal::CodeLocation,std::less,std::allocator<std::pair<const std::basic_string<char,std::char_traits,std::allocator>,testing::internal::CodeLocation>>>”

[7267/7574] Building CXX object test_jit\CMakeFiles\test_jit.dir\test_class_import.cpp.obj
ninja: build stopped: subcommand failed.

Versions

1.27.0

cc @chauhang @penguinwu

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions