Compiling CPP/CUDA extension composed of multiple files

username: marcman411
cooked: <p>Following <a href="https://pytorch.org/tutorials/advanced/cpp_extension.html" rel="nofollow noopener">the tutorial from Peter Goldsborough</a>, I’ve implemented a CPP and CUDA extension to PyTorch. However, according the tutorial compiles each as a separate module. In practice, it seems more useful to have a single module that enables both operations. I’ve split up my CUDA and CPP extensions, however, into separate files. While it compiles and works just fine in a pair of CPP and CUDA files like in the tutorial, it now fails miserably. All I’ve done is to separate the declarations into header files, the CPP code into its own file, and the CUDA code into its own file.</p>
<p>Right now, my <code>setup.py</code> looks like:</p>
<pre><code class="lang-auto">from setuptools import setup
from torch.utils.cpp_extension import BuildExtension, CUDAExtension, CppExtension

setup(
	name='test',
	ext_modules=[
		CUDAExtension(
			name='test', 
			sources=['bindings.cpp',
                                'test_cuda.cu',
				'other_test_cuda.cu',
				'test.cpp',
				'other_test.cpp'],
			include_dirs=['./include']
		),
	],
	cmdclass={
		'build_ext': BuildExtension
	})

</code></pre>
<p>and <code>jit.py</code> is:</p>
<pre><code class="lang-auto">from torch.utils.cpp_extension import load

test = load(
	name='test', 
	sources=['bindings.cpp', 
			'test.cpp', 
			'test_cuda.cu', 
			'other_test.cpp', 
			'other_test_cuda.cu'], 
		extra_include_paths=['./include']
    verbose=False)
help(test)
</code></pre>
<p>The sources are all my implementations, while I have the declarations (four files: <code>test.h</code>, <code>test.cuh</code>, <code>other_test.h</code>, and <code>other_test.cuh</code>) in the <code>./include</code> directory.</p>
<p>I moved the <code>PYBIND11_MODULE</code> to <code>bindings.cpp</code> as suggested by this <a href="https://www.google.com/url?q=https://stackoverflow.com/questions/50028830/pybind11-where-to-put-pybind11-module&amp;sa=D&amp;source=hangouts&amp;ust=1544222059493000&amp;usg=AFQjCNHhkBLh9h5mr4qlAfSL8ka45EdkhQ" rel="nofollow noopener">StackOverflow answer</a>. That file  looks like this:</p>
<pre><code class="lang-auto">#include &lt;torch/extension.h&gt;

#include "test.h"
#include "other_test.h"

PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) {
	m.def("test_a", &amp;test_a, "Test A");
	m.def("test_b", &amp;test_b, "Test B");
	m.def("other_test_a", &amp;other_test_a, "Other Test A");
	m.def("other_test_b", &amp;other_test_b, "Other Test B");
}
</code></pre>
<p>My files are laid out so that I have</p>
<pre><code class="lang-auto">-include
    -test.h
    -other_test.h
    -test.cuh
    -other_test.cuh
-test.cpp
-test.cu
-other_test.cpp
-other_test.cu
-bindings.cpp
-jit.py
-setup.py
</code></pre>
<p><strong>This all fails terribly when I try to build.</strong> It appears to be a PyBind11 issue, but because of PyTorch’s abstraction, it’s not obvious how to solve it looking through PyBind only. A sample of the error printout is below</p>
<p><code>python setup.py build</code></p>
<pre><code class="lang-auto">running build
running build_ext
building 'test' extension
/usr/local/cuda/bin/nvcc -I./include -I...torch/lib/include -I...torch/lib/include/torch/csrc/api/include -I...torch/lib/include/TH -I...torch/lib/include/THC -I/usr/local/cuda/include -I/data/anaconda3/envs/test/include/python3.7m -c test_cuda.cu -o build/temp.linux-x86_64-3.7/test_cuda.o -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --compiler-options '-fPIC' -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=other_test -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++11
...torch/lib/include/ATen/core/jit_type.h(945): warning: statement is unreachable

...torch/lib/include/pybind11/pytypes.h:1165:206: error: expansion pattern ‘pybind11::detail::negation&lt;std::is_same&lt;pybind11::detail::bools&lt;pybind11::detail::negation&lt;std::is_base_of&lt;pybind11::arg, Args&gt; &gt;::value ..., pybind11::detail::negation&lt;std::is_same&lt;pybind11::detail::kwargs_proxy, Args&gt; &gt;::value ..., true&gt;, pybind11::detail::bools&lt;true, pybind11::detail::negation&lt;std::is_base_of&lt;pybind11::arg, Args&gt; &gt;::value ..., pybind11::detail::negation&lt;std::is_same&lt;pybind11::detail::kwargs_proxy, Args&gt; &gt;::value ...&gt; &gt; &gt;::value’ contains no argument packs
...torch/lib/include/pybind11/pytypes.h:1165:215: error: template argument 1 is invalid
...torch/lib/include/pybind11/pytypes.h:1165:392: error: expansion pattern ‘pybind11::detail::negation&lt;std::is_same&lt;pybind11::detail::bools&lt;pybind11::detail::negation&lt;std::is_base_of&lt;pybind11::arg, Args&gt; &gt;::value ..., pybind11::detail::negation&lt;std::is_same&lt;pybind11::detail::kwargs_proxy, Args&gt; &gt;::value ..., true&gt;, pybind11::detail::bools&lt;true, pybind11::detail::negation&lt;std::is_base_of&lt;pybind11::arg, Args&gt; &gt;::value ..., pybind11::detail::negation&lt;std::is_same&lt;pybind11::detail::kwargs_proxy, Args&gt; &gt;::value ...&gt; &gt; &gt;::value’ contains no argument packs
...torch/lib/include/pybind11/pytypes.h:1165:395: error: template argument 2 is invalid
...torch/lib/include/pybind11/pytypes.h:1165:397: error: template argument 1 is invalid
...torch/lib/include/pybind11/pytypes.h:1165:397: error: template argument 2 is invalid
...torch/lib/include/pybind11/pytypes.h:1165:412: error: template argument 1 is invalid
...torch/lib/include/pybind11/cast.h:766:149: error: expansion pattern ‘std::is_copy_constructible&lt;_Tp&gt;::value’ contains no argument packs
...torch/lib/include/pybind11/cast.h:766:240: error: expansion pattern ‘std::is_same&lt;typename Container::value_type&amp;, typename Container::reference&gt;::value’ contains no argument packs
...torch/lib/include/pybind11/cast.h:766:249: error: template argument 1 is invalid
...torch/lib/include/pybind11/cast.h:766:249: error: template argument 2 is invalid
...torch/lib/include/pybind11/cast.h:766:312: error: expansion pattern ‘std::is_copy_constructible&lt;_Tp&gt;::value’ contains no argument packs
...torch/lib/include/pybind11/cast.h:766:403: error: expansion pattern ‘std::is_same&lt;typename Container::value_type&amp;, typename Container::reference&gt;::value’ contains no argument packs
...torch/lib/include/pybind11/cast.h:766:406: error: template argument 2 is invalid
...torch/lib/include/pybind11/cast.h:766:406: error: template argument 3 is invalid
...torch/lib/include/pybind11/cast.h:766:408: error: template argument 1 is invalid
...torch/lib/include/pybind11/cast.h:766:408: error: template argument 2 is invalid
...torch/lib/include/pybind11/cast.h:766:423: error: template argument 1 is invalid
...torch/lib/include/pybind11/cast.h:766:425: error: template argument 2 is invalid
...torch/lib/include/pybind11/cast.h:960:126: error: expansion pattern ‘pybind11::detail::negation&lt;std::is_same&lt;CharT, char&gt; &gt;’ contains no argument packs
...torch/lib/include/pybind11/cast.h:960:170: error: expansion pattern ‘pybind11::detail::negation&lt;std::is_same&lt;CharT, char16_t&gt; &gt;’ contains no argument packs
...torch/lib/include/pybind11/cast.h:960:214: error: expansion pattern ‘pybind11::detail::negation&lt;std::is_same&lt;CharT, char32_t&gt; &gt;’ contains no argument packs
...torch/lib/include/pybind11/cast.h:960:257: error: expansion pattern ‘pybind11::detail::negation&lt;std::is_same&lt;CharT, wchar_t&gt; &gt;’ contains no argument packs
...torch/lib/include/pybind11/cast.h:960:260: error: template argument 1 is invalid
...torch/lib/include/pybind11/cast.h:960:260: error: template argument 2 is invalid
...torch/lib/include/pybind11/cast.h:960:260: error: template argument 3 is invalid
...torch/lib/include/pybind11/cast.h:960:260: error: template argument 4 is invalid
...torch/lib/include/pybind11/cast.h:960:262: error: template argument 1 is invalid
...torch/lib/include/pybind11/cast.h:1250:138: error: expansion pattern ‘pybind11::detail::negation&lt;std::is_same&lt;CharT, char&gt; &gt;’ contains no argument packs
...torch/lib/include/pybind11/cast.h:1250:186: error: expansion pattern ‘pybind11::detail::negation&lt;std::is_same&lt;CharT, char16_t&gt; &gt;’ contains no argument packs
...torch/lib/include/pybind11/cast.h:1250:234: error: expansion pattern ‘pybind11::detail::negation&lt;std::is_same&lt;CharT, char32_t&gt; &gt;’ contains no argument packs
...torch/lib/include/pybind11/cast.h:1250:281: error: expansion pattern ‘pybind11::detail::negation&lt;std::is_same&lt;CharT, wchar_t&gt; &gt;’ contains no argument packs
...torch/lib/include/pybind11/cast.h:1250:284: error: template argument 1 is invalid
...torch/lib/include/pybind11/cast.h:1250:284: error: template argument 2 is invalid
...torch/lib/include/pybind11/cast.h:1250:284: error: template argument 3 is invalid
...torch/lib/include/pybind11/cast.h:1250:284: error: template argument 4 is invalid
...torch/lib/include/pybind11/cast.h:1250:286: error: template argument 1 is invalid
...torch/lib/include/pybind11/cast.h:1250:301: error: template argument 1 is invalid
...torch/lib/include/pybind11/cast.h:1250:303: error: template argument 2 is invalid
...torch/lib/include/pybind11/cast.h:1261:121: error: expansion pattern ‘pybind11::detail::negation&lt;std::is_same&lt;CharT, char&gt; &gt;’ contains no argument packs
...torch/lib/include/pybind11/cast.h:1261:169: error: expansion pattern ‘pybind11::detail::negation&lt;std::is_same&lt;CharT, char16_t&gt; &gt;’ contains no argument packs
...torch/lib/include/pybind11/cast.h:1261:217: error: expansion pattern ‘pybind11::detail::negation&lt;std::is_same&lt;CharT, char32_t&gt; &gt;’ contains no argument packs
...torch/lib/include/pybind11/cast.h:1261:264: error: expansion pattern ‘pybind11::detail::negation&lt;std::is_same&lt;CharT, wchar_t&gt; &gt;’ contains no argument packs
...torch/lib/include/pybind11/cast.h:1261:267: error: template argument 1 is invalid
...torch/lib/include/pybind11/cast.h:1261:267: error: template argument 2 is invalid
...torch/lib/include/pybind11/cast.h:1261:267: error: template argument 3 is invalid
...torch/lib/include/pybind11/cast.h:1261:267: error: template argument 4 is invalid
...torch/lib/include/pybind11/cast.h:1261:269: error: template argument 1 is invalid
...torch/lib/include/pybind11/cast.h:1261:284: error: template argument 1 is invalid
...torch/lib/include/pybind11/cast.h:1261:286: error: template argument 2 is invalid
...torch/lib/include/pybind11/cast.h:1583:112: error: expansion pattern ‘std::is_void&lt;_Tp&gt;’ contains no argument packs
...torch/lib/include/pybind11/cast.h:1583:137: error: expansion pattern ‘std::is_pointer&lt;_Tp&gt;’ contains no argument packs
...torch/lib/include/pybind11/cast.h:1583:164: error: expansion pattern ‘std::is_reference&lt;_Tp&gt;’ contains no argument packs
...torch/lib/include/pybind11/cast.h:1583:187: error: expansion pattern ‘std::is_const&lt;_Tp&gt;’ contains no argument packs
...torch/lib/include/pybind11/cast.h:1583:190: error: template argument 1 is invalid
...torch/lib/include/pybind11/cast.h:1583:190: error: template argument 2 is invalid
...torch/lib/include/pybind11/cast.h:1583:190: error: template argument 3 is invalid
...torch/lib/include/pybind11/cast.h:1583:190: error: template argument 4 is invalid
...torch/lib/include/pybind11/cast.h:1583:192: error: template argument 1 is invalid
...torch/lib/include/pybind11/cast.h:1583:201: error: expected parameter pack before ‘...’
...torch/lib/include/pybind11/cast.h:1583:251: error: expansion pattern ‘pybind11::detail::negation&lt;pybind11::detail::is_copy_constructible&lt;T1&gt; &gt;::value’ contains no argument packs
...torch/lib/include/pybind11/cast.h:1583:294: error: expansion pattern ‘std::is_move_constructible&lt;_Tp&gt;::value’ contains no argument packs
...torch/lib/include/pybind11/cast.h:1583:392: error: expansion pattern ‘std::is_same&lt;decltype (declval&lt;pybind11::detail::type_caster&lt;typename pybind11::detail::intrinsic_type&lt;T&gt;::type, void&gt; &gt;().operator T&amp;()), T&amp;&gt;::value’ contains no argument packs
...torch/lib/include/pybind11/cast.h:1583:401: error: template argument 1 is invalid
...torch/lib/include/pybind11/cast.h:1583:401: error: template argument 2 is invalid
...torch/lib/include/pybind11/cast.h:1583:401: error: template argument 3 is invalid
...torch/lib/include/pybind11/cast.h:1583:401: error: template argument 4 is invalid
...torch/lib/include/pybind11/cast.h:1583:453: error: expansion pattern ‘std::is_void&lt;_Tp&gt;’ contains no argument packs
...torch/lib/include/pybind11/cast.h:1583:478: error: expansion pattern ‘std::is_pointer&lt;_Tp&gt;’ contains no argument packs
...torch/lib/include/pybind11/cast.h:1583:505: error: expansion pattern ‘std::is_reference&lt;_Tp&gt;’ contains no argument packs
...torch/lib/include/pybind11/cast.h:1583:528: error: expansion pattern ‘std::is_const&lt;_Tp&gt;’ contains no argument packs
...torch/lib/include/pybind11/cast.h:1583:531: error: template argument 1 is invalid
...torch/lib/include/pybind11/cast.h:1583:531: error: template argument 2 is invalid
...torch/lib/include/pybind11/cast.h:1583:531: error: template argument 3 is invalid
...torch/lib/include/pybind11/cast.h:1583:531: error: template argument 4 is invalid
...torch/lib/include/pybind11/cast.h:1583:533: error: template argument 1 is invalid
...torch/lib/include/pybind11/cast.h:1583:542: error: expected parameter pack before ‘...’
...torch/lib/include/pybind11/cast.h:1583:592: error: expansion pattern ‘pybind11::detail::negation&lt;pybind11::detail::is_copy_constructible&lt;T1&gt; &gt;::value’ contains no argument packs
...torch/lib/include/pybind11/cast.h:1583:635: error: expansion pattern ‘std::is_move_constructible&lt;_Tp&gt;::value’ contains no argument packs
...torch/lib/include/pybind11/cast.h:1583:733: error: expansion pattern ‘std::is_same&lt;decltype (declval&lt;pybind11::detail::type_caster&lt;typename pybind11::detail::intrinsic_type&lt;T&gt;::type, void&gt; &gt;().operator T&amp;()), T&amp;&gt;::value’ contains no argument packs
...torch/lib/include/pybind11/cast.h:1583:736: error: template argument 2 is invalid
...torch/lib/include/pybind11/cast.h:1583:736: error: template argument 3 is invalid
...torch/lib/include/pybind11/cast.h:1583:736: error: template argument 4 is invalid
...torch/lib/include/pybind11/cast.h:1583:736: error: template argument 5 is invalid
...torch/lib/include/pybind11/cast.h:1583:738: error: template argument 1 is invalid
...torch/lib/include/pybind11/cast.h:1583:738: error: template argument 2 is invalid
...torch/lib/include/pybind11/cast.h:1583:753: error: template argument 1 is invalid
...torch/lib/include/pybind11/cast.h:1583:755: error: template argument 2 is invalid
...torch/lib/include/pybind11/cast.h:1590:121: error: expansion pattern ‘std::is_void&lt;_Tp&gt;’ contains no argument packs
...torch/lib/include/pybind11/cast.h:1590:146: error: expansion pattern ‘std::is_pointer&lt;_Tp&gt;’ contains no argument packs
...torch/lib/include/pybind11/cast.h:1590:173: error: expansion pattern ‘std::is_reference&lt;_Tp&gt;’ contains no argument packs
...torch/lib/include/pybind11/cast.h:1590:196: error: expansion pattern ‘std::is_const&lt;_Tp&gt;’ contains no argument packs
...torch/lib/include/pybind11/cast.h:1590:199: error: template argument 1 is invalid
...torch/lib/include/pybind11/cast.h:1590:199: error: template argument 2 is invalid
...torch/lib/include/pybind11/cast.h:1590:199: error: template argument 3 is invalid
...torch/lib/include/pybind11/cast.h:1590:199: error: template argument 4 is invalid
...torch/lib/include/pybind11/cast.h:1590:201: error: template argument 1 is invalid
...torch/lib/include/pybind11/cast.h:1590:210: error: expected parameter pack before ‘...’
...torch/lib/include/pybind11/cast.h:1590:250: error: expansion pattern ‘pybind11::detail::negation&lt;pybind11::detail::move_always&lt;T&gt; &gt;::value’ contains no argument packs
...torch/lib/include/pybind11/cast.h:1590:293: error: expansion pattern ‘std::is_move_constructible&lt;_Tp&gt;::value’ contains no argument packs
...torch/lib/include/pybind11/cast.h:1590:391: error: expansion pattern ‘std::is_same&lt;decltype (declval&lt;pybind11::detail::type_caster&lt;typename pybind11::detail::intrinsic_type&lt;T&gt;::type, void&gt; &gt;().operator T&amp;()), T&amp;&gt;::value’ contains no argument packs
...torch/lib/include/pybind11/cast.h:1590:400: error: template argument 1 is invalid
...torch/lib/include/pybind11/cast.h:1590:400: error: template argument 2 is invalid
...torch/lib/include/pybind11/cast.h:1590:400: error: template argument 3 is invalid
...torch/lib/include/pybind11/cast.h:1590:400: error: template argument 4 is invalid
...torch/lib/include/pybind11/cast.h:1590:452: error: expansion pattern ‘std::is_void&lt;_Tp&gt;’ contains no argument packs
...torch/lib/include/pybind11/cast.h:1590:477: error: expansion pattern ‘std::is_pointer&lt;_Tp&gt;’ contains no argument packs
...torch/lib/include/pybind11/cast.h:1590:504: error: expansion pattern ‘std::is_reference&lt;_Tp&gt;’ contains no argument packs
...torch/lib/include/pybind11/cast.h:1590:527: error: expansion pattern ‘std::is_const&lt;_Tp&gt;’ contains no argument packs
...torch/lib/include/pybind11/cast.h:1590:530: error: template argument 1 is invalid
...torch/lib/include/pybind11/cast.h:1590:530: error: template argument 2 is invalid
...torch/lib/include/pybind11/cast.h:1590:530: error: template argument 3 is invalid
...torch/lib/include/pybind11/cast.h:1590:530: error: template argument 4 is invalid
...torch/lib/include/pybind11/cast.h:1590:532: error: template argument 1 is invalid
...torch/lib/include/pybind11/cast.h:1590:541: error: expected parameter pack before ‘...’
...torch/lib/include/pybind11/cast.h:1590:581: error: expansion pattern ‘pybind11::detail::negation&lt;pybind11::detail::move_always&lt;T&gt; &gt;::value’ contains no argument packs
...torch/lib/include/pybind11/cast.h:1590:624: error: expansion pattern ‘std::is_move_constructible&lt;_Tp&gt;::value’ contains no argument packs
...torch/lib/include/pybind11/cast.h:1590:722: error: expansion pattern ‘std::is_same&lt;decltype (declval&lt;pybind11::detail::type_caster&lt;typename pybind11::detail::intrinsic_type&lt;T&gt;::type, void&gt; &gt;().operator T&amp;()), T&amp;&gt;::value’ contains no argument packs
...torch/lib/include/pybind11/cast.h:1590:725: error: template argument 2 is invalid
...torch/lib/include/pybind11/cast.h:1590:725: error: template argument 3 is invalid
...torch/lib/include/pybind11/cast.h:1590:725: error: template argument 4 is invalid
...torch/lib/include/pybind11/cast.h:1590:725: error: template argument 5 is invalid
...torch/lib/include/pybind11/cast.h:1590:727: error: template argument 1 is invalid
...torch/lib/include/pybind11/cast.h:1590:727: error: template argument 2 is invalid
...torch/lib/include/pybind11/cast.h:1590:742: error: template argument 1 is invalid
...torch/lib/include/pybind11/cast.h:1590:744: error: template argument 2 is invalid
...torch/lib/include/pybind11/cast.h:1670:100: error: expansion pattern ‘pybind11::detail::move_always&lt;T&gt;’ contains no argument packs
...torch/lib/include/pybind11/cast.h:1670:138: error: expansion pattern ‘pybind11::detail::move_if_unreferenced&lt;T&gt;’ contains no argument packs
...torch/lib/include/pybind11/cast.h:1670:141: error: template argument 1 is invalid
...torch/lib/include/pybind11/cast.h:1670:141: error: template argument 2 is invalid
...torch/lib/include/pybind11/cast.h:1670:143: error: template argument 1 is invalid
...torch/lib/include/pybind11/cast.h:1670:155: error: template argument 1 is invalid
...torch/lib/include/pybind11/cast.h:1700:99: error: expansion pattern ‘pybind11::detail::move_always&lt;T&gt;’ contains no argument packs
...torch/lib/include/pybind11/cast.h:1700:137: error: expansion pattern ‘pybind11::detail::move_if_unreferenced&lt;T&gt;’ contains no argument packs
...torch/lib/include/pybind11/cast.h:1700:140: error: template argument 1 is invalid
...torch/lib/include/pybind11/cast.h:1700:140: error: template argument 2 is invalid
...torch/lib/include/pybind11/cast.h:1700:142: error: template argument 1 is invalid
...torch/lib/include/pybind11/cast.h:1700:154: error: template argument 1 is invalid
...torch/lib/include/pybind11/cast.h:2074:145: error: expansion pattern ‘pybind11::detail::negation&lt;pybind11::detail::negation&lt;std::is_same&lt;pybind11::detail::bools&lt;pybind11::detail::negation&lt;std::is_base_of&lt;pybind11::arg, Args&gt; &gt;::value ..., pybind11::detail::negation&lt;std::is_same&lt;pybind11::detail::args_proxy, Args&gt; &gt;::value ..., pybind11::detail::negation&lt;std::is_same&lt;pybind11::detail::kwargs_proxy, Args&gt; &gt;::value ..., true&gt;, pybind11::detail::bools&lt;true, pybind11::detail::negation&lt;std::is_base_of&lt;pybind11::arg, Args&gt; &gt;::value ..., pybind11::detail::negation&lt;std::is_same&lt;pybind11::detail::args_proxy, Args&gt; &gt;::value ..., pybind11::detail::negation&lt;std::is_same&lt;pybind11::detail::kwargs_proxy, Args&gt; &gt;::value ...&gt; &gt; &gt; &gt;::value’ contains no argument packs
...torch/lib/include/pybind11/cast.h:2074:154: error: template argument 1 is invalid
...torch/lib/include/pybind11/cast.h:2074:278: error: expansion pattern ‘pybind11::detail::negation&lt;pybind11::detail::negation&lt;std::is_same&lt;pybind11::detail::bools&lt;pybind11::detail::negation&lt;std::is_base_of&lt;pybind11::arg, Args&gt; &gt;::value ..., pybind11::detail::negation&lt;std::is_same&lt;pybind11::detail::args_proxy, Args&gt; &gt;::value ..., pybind11::detail::negation&lt;std::is_same&lt;pybind11::detail::kwargs_proxy, Args&gt; &gt;::value ..., true&gt;, pybind11::detail::bools&lt;true, pybind11::detail::negation&lt;std::is_base_of&lt;pybind11::arg, Args&gt; &gt;::value ..., pybind11::detail::negation&lt;std::is_same&lt;pybind11::detail::args_proxy, Args&gt; &gt;::value ..., pybind11::detail::negation&lt;std::is_same&lt;pybind11::detail::kwargs_proxy, Args&gt; &gt;::value ...&gt; &gt; &gt; &gt;::value’ contains no argument packs
...torch/lib/include/pybind11/cast.h:2074:281: error: template argument 2 is invalid
...torch/lib/include/pybind11/cast.h:2074:283: error: template argument 1 is invalid
...torch/lib/include/pybind11/cast.h:2074:283: error: template argument 2 is invalid
...torch/lib/include/pybind11/cast.h:2074:298: error: template argument 1 is invalid
...
</code></pre>
<p>This goes on for hundreds of more lines.</p>
<p>Does anyone know how to build a PyTorch module extension where the module is broken up into more than two files?</p>

username: makezur
cooked: <p>Have you solved this issue?</p>
<p>edit: the solution is to make sure you haven’t included torch/extension.h in .cu files.</p>

username: xyegithub
cooked: <p>That is the reason. But if I do not include torch/extension.h in .cu files,  how can I use Tensor? Is there any method? <div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/2X/9/91e4576876c1a5e2c5f96ed0312971787c14b538.png" data-download-href="https://discuss.pytorch.org/uploads/default/91e4576876c1a5e2c5f96ed0312971787c14b538" title="1557801191(1)"><img src="https://discuss.pytorch.org/uploads/default/original/2X/9/91e4576876c1a5e2c5f96ed0312971787c14b538.png" alt="1557801191(1)" data-base62-sha1="kOCs3mQLnDvAfZjdoAk3iBrwdcc" width="689" height="210" data-dominant-color="131514"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">1557801191(1)</span><span class="informations">1279×390 12.9 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>

username: xyegithub
cooked: <p>Have you solved this issue?</p>

username: makezur
cooked: <p>use <code>#include &lt;torch/types.h&gt;</code></p>

username: xyegithub
cooked: <p>It works.  Many thanks.</p>