pytorch / extension-cpp

C++ extensions in PyTorch
1.02k stars 214 forks source link

CUDA extension compilation failed on MacOS 10.13.6 with Pytorch 1.5.0 #58

Open TomHeaven opened 4 years ago

TomHeaven commented 4 years ago

When submitting a bug report, please include the following information (where relevant):

In addition, including the following information will also be very helpful for us to diagnose the problem:

The error seems to be from pytorch's header file variant.h(2241).

template <typename... Ts>
  class variant {
    static_assert(0 < sizeof...(Ts),
                  "variant must consist of at least one alternative.");

    static_assert(lib::all<!std::is_array<Ts>::value...>::value,
                  "variant can not have an array type as an alternative.");

    static_assert(lib::all<!std::is_reference<Ts>::value...>::value,
                  "variant can not have a reference type as an alternative.");

    static_assert(lib::all<!std::is_void<Ts>::value...>::value,
                  "variant can not have a void type as an alternative.");

    public:
    template <
        typename Front = lib::type_pack_element_t<0, Ts...>, // Line 2241. The error is in this line.
        lib::enable_if_t<std::is_default_constructible<Front>::value, int> = 0>
    inline constexpr variant() noexcept(
        std::is_nothrow_default_constructible<Front>::value)
        : impl_(in_place_index_t<0>{}) {}
zhanghang1989 commented 4 years ago

Any followup or solutions?

hoffbrinkle commented 3 years ago

The crux of it is here:

https://github.com/pytorch/pytorch/blob/5acc27c00a131c3e8ce4dad6e06222bb40f30dc7/c10/util/variant.h#L281

clang supports a __type_pack_element builtin. So the code will be generated using that. However, some downstream Nvidia tools, not so much. I think it's cudafe++ that can't handle it. In any case, comment out that check or whatever you need to do to make MPARK_TYPE_PACK_ELEMENT be undefined. The code will then be generated which will use generic unpacking from a pack.