Compile JIT from source to support CUDA

username: Ssicayoon
cooked: <p>Could you tell the bug in the following codes?</p>
<p>pytorch/torch/csrc/jit/codegen/cuda/manager.cpp</p>
<blockquote>
<p>namespace {<br>
std::unique_ptr makePWKernelSupport(<br>
const at::ArrayRef&amp; inputs) {<br>
auto req_ptr = std::make_unique();<br>
for (const auto&amp; input : inputs) {<br>
req_ptr-&gt;dims_.push_back(input.isTensor() ? input.toTensor().dim() : -1);<br>
}<br>
return req_ptr;<br>
}</p>
</blockquote>
<p>C++ compiler told me there is an error resulted from copying unique_ptr?<br>
I am not a C++ expert, so I cannot tell where the wrong code is and how to fix it.</p>

username: ptrblck
cooked: <p>What kind of error did you see?<br>
Could you post the complete error message, please?</p>

username: Ssicayoon
cooked: <p>Thanks for your reply.<br>
To compile cuda-support pytorch from source, I encountered some problems.</p>
<p>First, by following the latest guide in github README, the error occurred.</p>
<blockquote>
<p>…/torch/csrc/jit/codegen/cuda/manager.cpp:75:58:   required from here<br>
/usr/include/c++/5/bits/stl_construct.h:75:7: error: use of deleted function ‘constexpr std::pair&lt;_T1, _T2&gt;::pair(const std::pair&lt;_T1, _T2&gt;&amp;) [with _T1 = std::unique_ptr<a>torch::jit::fuser::cuda::KernelArgsReq</a>; _T2 = torch::jit::fuser::cuda::CudaKernel]’<br>
{ ::new(static_cast&lt;void*&gt;(__p)) _T1(std::forward&lt;_Args&gt;(__args)…); }</p>
</blockquote>
<p>I modified <code>/torch/csrc/jit/codegen/cuda/manager.cpp:75</code><br>
from</p>
<blockquote>
<p>kernel_cache_.insert({kernel_id, CudaKernelCache()});</p>
</blockquote>
<p>to</p>
<blockquote>
<p>kernel_cache_.insert(std::make_pair(std::move(kernel_id), CudaKernelCache()));</p>
</blockquote>
<p>After modification, the compilation can go on, but a new error comes out.</p>
<blockquote>
<p>…/test/cpp/jit/test_gpu.cpp:1633:47: error: converting to ‘std::tuple&lt;at::Tensor (<em>)(const at::Tensor&amp;), torch::jit::fuser::UnaryOpType, std::__cxx11::basic_string&lt;char, std::char_traits, std::allocator &gt; &gt;’ from initializer list would use explicit constructor ‘constexpr std::tuple&lt;  &gt;::tuple(_UElements&amp;&amp; …) [with _UElements = {at::Tensor (&amp;)(const at::Tensor&amp;), torch::jit::fuser::UnaryOpType, const char (&amp;)[4]};  = void; _Elements = {at::Tensor (</em>)(const at::Tensor&amp;), torch::jit::fuser::UnaryOpType, std::__cxx11::basic_string&lt;char, std::char_traits, std::allocator &gt;}]’<br>
{at::trunc, UnaryOpType::Trunc, “trunc”}};</p>
</blockquote>
<p>I noticed <code>std::__cxx11::basic_string</code>, so I guess cuda-supported pytorch should be compiled with C++11 instead of C++14. I am about to verify my guess.</p>
<p>Do you have any suggestions?</p>

username: ptrblck
cooked: <p>You would need a C++14 compiler as given in the <a href="https://github.com/pytorch/pytorch#from-source">build instructions</a>:</p>
<blockquote>
<p>If you are installing from source, you will need a C++14 compiler.</p>
</blockquote>

username: Ssicayoon
cooked: <p>Now I am using C++14, but errors comes out.<br>
So what do you think about the second error?</p>
<blockquote>
<p>…/test/cpp/jit/test_gpu.cpp:1633:47: error: converting to ‘std::tuple&lt;at::Tensor ( <em>)(const at::Tensor&amp;), torch::jit::fuser::UnaryOpType, std::__cxx11::basic_string&lt;char, std::char_traits, std::allocator &gt; &gt;’ from initializer list would use explicit constructor ‘constexpr std::tuple&lt; &gt;::tuple(_UElements&amp;&amp; …) [with _UElements = {at::Tensor (&amp;)(const at::Tensor&amp;), torch::jit::fuser::UnaryOpType, const char (&amp;)[4]}; = void; _Elements = {at::Tensor (</em> )(const at::Tensor&amp;), torch::jit::fuser::UnaryOpType, std::__cxx11::basic_string&lt;char, std::char_traits, std::allocator &gt;}]’<br>
{at::trunc, UnaryOpType::Trunc, “trunc”}};</p>
</blockquote>
<p>Is there a solution?<br>
Thank you!</p>

username: Ssicayoon
cooked: <p>I have passed the compilation and the CUDA can be detected correctly.<br>
For the second error, I commented all the related tuple initialization in <code>/home/lim/Desktop/GithubRepo/pytorch/test/cpp/jit/test_gpu.cpp</code>.</p>