<h2 dir="auto"><g-emoji class="g-emoji" alias="bug" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f41b.png">🐛</g-emoji> Bug</h2>
<p dir="auto">When using PyTorch1.3 C++ distribution in Visual Studio 2017 and follow the tutorial of loading a TorchScript model from C++ described here <a href="https://pytorch.org/tutorials/advanced/cpp_export.html" rel="nofollow">https://pytorch.org/tutorials/advanced/cpp_export.html</a></p>
<p dir="auto">It all works fine as long as the model and the tensor data stays on the CPU, but as soon as I try to move the model to GPU (CUDA) via</p>
<p dir="auto">.to(at::kCUDA) I'll get a crash when using the debug version of the libraries. and I'll get a crash later in the release version in the .forward method</p>
<h2 dir="auto">To Reproduce</h2>
<p dir="auto">Steps to reproduce the behavior:</p>
<ol dir="auto">
<li>Use the code from the tutorial page above</li>
<li>Download latest Windows10 debug version from website</li>
<li>Create a new VS2017 project and use the code snippets above</li>
<li>Use the include/libraries from the debug version</li>
<li>Try to run the code inside VS2017</li>
</ol>
<p dir="auto">Stacktrace:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="torch.dll!at::native::DispatchStub&lt;void (__cdecl*)(at::TensorIterator &amp; __ptr64,bool),at::native::copy_stub&gt;::operator()&lt;at::TensorIterator &amp; __ptr64,bool &amp; __ptr64&gt;(c10::DeviceType device_type, at::TensorIterator &amp; &lt;args_0&gt;, bool &amp; &lt;args_1&gt;) Line 74	C++
torch.dll!at::native::copy_impl(at::Tensor &amp; self, const at::Tensor &amp; src, bool non_blocking) Line 148	C++
torch.dll!at::native::copy_(at::Tensor &amp; self, const at::Tensor &amp; src, bool non_blocking) Line 157	C++
torch.dll!at::TypeDefault::copy_(at::Tensor &amp; self, const at::Tensor &amp; src, bool non_blocking) Line 1246	C++
torch.dll!c10::detail::WrapRuntimeKernelFunctor_&lt;at::Tensor &amp; __ptr64 (__cdecl*)(at::Tensor &amp; __ptr64,at::Tensor const &amp; __ptr64,bool),at::Tensor &amp; __ptr64,c10::guts::typelist::typelist&lt;at::Tensor &amp; __ptr64,at::Tensor const &amp; __ptr64,bool&gt; &gt;::operator()(at::Tensor &amp; &lt;args_0&gt;, const at::Tensor &amp; &lt;args_1&gt;, bool &lt;args_2&gt;) Line 24	C++
torch.dll!c10::detail::wrap_kernel_functor_unboxed_&lt;c10::detail::WrapRuntimeKernelFunctor_&lt;at::Tensor &amp; __ptr64 (__cdecl*)(at::Tensor &amp; __ptr64,at::Tensor const &amp; __ptr64,bool),at::Tensor &amp; __ptr64,c10::guts::typelist::typelist&lt;at::Tensor &amp; __ptr64,at::Tensor const &amp; __ptr64,bool&gt; &gt;,at::Tensor &amp; __ptr64 __cdecl(at::Tensor &amp; __ptr64,at::Tensor const &amp; __ptr64,bool)&gt;::call(c10::OperatorKernel * functor, at::Tensor &amp; &lt;args_0&gt;, const at::Tensor &amp; &lt;args_1&gt;, bool &lt;args_2&gt;) Line 261	C++
torch.dll!c10::KernelFunction::callUnboxedOnly&lt;at::Tensor &amp; __ptr64,at::Tensor &amp; __ptr64,at::Tensor const &amp; __ptr64,bool&gt;(at::Tensor &amp; &lt;args_0&gt;, const at::Tensor &amp; &lt;args_1&gt;, bool &lt;args_2&gt;) Line 95	C++
torch.dll!c10::impl::OperatorEntry::callUnboxedOnly::__l2::&lt;lambda&gt;(const c10::DispatchTable &amp; dispatchTable) Line 68	C++
torch.dll!c10::LeftRight&lt;c10::DispatchTable&gt;::read&lt;at::Tensor &amp; &lt;lambda&gt;(const c10::DispatchTable &amp;) &gt;(c10::impl::OperatorEntry::callUnboxedOnly::__l2::at::Tensor &amp; &lt;lambda&gt;(const c10::DispatchTable &amp;) &amp;&amp; readFunc) Line 74	C++
torch.dll!c10::impl::OperatorEntry::callUnboxedOnly&lt;at::Tensor &amp; __ptr64,at::Tensor &amp; __ptr64,at::Tensor const &amp; __ptr64,bool&gt;(c10::TensorTypeId dispatchKey, at::Tensor &amp; &lt;args_0&gt;, const at::Tensor &amp; &lt;args_1&gt;, bool &lt;args_2&gt;) Line 70	C++
torch.dll!c10::Dispatcher::callUnboxedOnly&lt;at::Tensor &amp; __ptr64,at::Tensor &amp; __ptr64,at::Tensor const &amp; __ptr64,bool&gt;(const c10::OperatorHandle &amp; op, c10::TensorTypeId dispatchKey, at::Tensor &amp; &lt;args_0&gt;, const at::Tensor &amp; &lt;args_1&gt;, bool &lt;args_2&gt;) Line 177	C++
torch.dll!at::Tensor::copy_(const at::Tensor &amp; src, bool non_blocking) Line 746	C++
torch.dll!torch::autograd::VariableType::copy_(at::Tensor &amp; self, const at::Tensor &amp; src, bool non_blocking) Line 151	C++
torch.dll!c10::detail::WrapRuntimeKernelFunctor_&lt;at::Tensor &amp; __ptr64 (__cdecl*)(at::Tensor &amp; __ptr64,at::Tensor const &amp; __ptr64,bool),at::Tensor &amp; __ptr64,c10::guts::typelist::typelist&lt;at::Tensor &amp; __ptr64,at::Tensor const &amp; __ptr64,bool&gt; &gt;::operator()(at::Tensor &amp; &lt;args_0&gt;, const at::Tensor &amp; &lt;args_1&gt;, bool &lt;args_2&gt;) Line 24	C++
torch.dll!c10::detail::wrap_kernel_functor_unboxed_&lt;c10::detail::WrapRuntimeKernelFunctor_&lt;at::Tensor &amp; __ptr64 (__cdecl*)(at::Tensor &amp; __ptr64,at::Tensor const &amp; __ptr64,bool),at::Tensor &amp; __ptr64,c10::guts::typelist::typelist&lt;at::Tensor &amp; __ptr64,at::Tensor const &amp; __ptr64,bool&gt; &gt;,at::Tensor &amp; __ptr64 __cdecl(at::Tensor &amp; __ptr64,at::Tensor const &amp; __ptr64,bool)&gt;::call(c10::OperatorKernel * functor, at::Tensor &amp; &lt;args_0&gt;, const at::Tensor &amp; &lt;args_1&gt;, bool &lt;args_2&gt;) Line 261	C++
torch.dll!c10::KernelFunction::callUnboxedOnly&lt;at::Tensor &amp; __ptr64,at::Tensor &amp; __ptr64,at::Tensor const &amp; __ptr64,bool&gt;(at::Tensor &amp; &lt;args_0&gt;, const at::Tensor &amp; &lt;args_1&gt;, bool &lt;args_2&gt;) Line 95	C++
torch.dll!c10::impl::OperatorEntry::callUnboxedOnly::__l2::&lt;lambda&gt;(const c10::DispatchTable &amp; dispatchTable) Line 68	C++
torch.dll!c10::LeftRight&lt;c10::DispatchTable&gt;::read&lt;at::Tensor &amp; &lt;lambda&gt;(const c10::DispatchTable &amp;) &gt;(c10::impl::OperatorEntry::callUnboxedOnly::__l2::at::Tensor &amp; &lt;lambda&gt;(const c10::DispatchTable &amp;) &amp;&amp; readFunc) Line 74	C++
torch.dll!c10::impl::OperatorEntry::callUnboxedOnly&lt;at::Tensor &amp; __ptr64,at::Tensor &amp; __ptr64,at::Tensor const &amp; __ptr64,bool&gt;(c10::TensorTypeId dispatchKey, at::Tensor &amp; &lt;args_0&gt;, const at::Tensor &amp; &lt;args_1&gt;, bool &lt;args_2&gt;) Line 70	C++
torch.dll!c10::Dispatcher::callUnboxedOnly&lt;at::Tensor &amp; __ptr64,at::Tensor &amp; __ptr64,at::Tensor const &amp; __ptr64,bool&gt;(const c10::OperatorHandle &amp; op, c10::TensorTypeId dispatchKey, at::Tensor &amp; &lt;args_0&gt;, const at::Tensor &amp; &lt;args_1&gt;, bool &lt;args_2&gt;) Line 177	C++
torch.dll!at::Tensor::copy_(const at::Tensor &amp; src, bool non_blocking) Line 746	C++
torch.dll!at::native::to_impl(const at::Tensor &amp; self, const c10::TensorOptions &amp; options, bool non_blocking) Line 25	C++
torch.dll!at::native::to(const at::Tensor &amp; self, c10::Device device, c10::ScalarType dtype, bool non_blocking, bool copy) Line 63	C++
torch.dll!at::TypeDefault::to(const at::Tensor &amp; self, c10::Device device, c10::ScalarType dtype, bool non_blocking, bool copy) Line 4830	C++
torch.dll!torch::autograd::VariableType::`anonymous namespace'::to(const at::Tensor &amp; self, c10::Device device, c10::ScalarType dtype, bool non_blocking, bool copy) Line 11390	C++
torch.dll!at::ATenOpTable::callUnboxed&lt;at::Tensor,at::Tensor const &amp; __ptr64,c10::Device,enum c10::ScalarType,bool,bool&gt;(const at::Tensor &amp; &lt;args_0&gt;, c10::Device &lt;args_1&gt;, c10::ScalarType &lt;args_2&gt;, bool &lt;args_3&gt;, bool &lt;args_4&gt;) Line 94	C++
torch.dll!at::Tensor::to(c10::Device device, c10::ScalarType dtype, bool non_blocking, bool copy) Line 3387	C++
torch.dll!torch::jit::script::module_state_to(const torch::jit::script::Slot &amp; s, const c10::optional&lt;c10::Device&gt; &amp; device, const c10::optional&lt;enum c10::ScalarType&gt; &amp; dtype, bool non_blocking) Line 123	C++
torch.dll!torch::jit::script::Module::to_impl(const c10::optional&lt;c10::Device&gt; &amp; device, const c10::optional&lt;enum c10::ScalarType&gt; &amp; dtype, bool non_blocking) Line 140	C++
torch.dll!torch::jit::script::Module::to_impl(const c10::optional&lt;c10::Device&gt; &amp; device, const c10::optional&lt;enum c10::ScalarType&gt; &amp; dtype, bool non_blocking) Line 136	C++
torch.dll!torch::jit::script::Module::to_impl(const c10::optional&lt;c10::Device&gt; &amp; device, const c10::optional&lt;enum c10::ScalarType&gt; &amp; dtype, bool non_blocking) Line 136	C++
torch.dll!torch::jit::script::Module::to(c10::Device device, bool non_blocking) Line 79	C++"><pre class="notranslate"><code class="notranslate">torch.dll!at::native::DispatchStub&lt;void (__cdecl*)(at::TensorIterator &amp; __ptr64,bool),at::native::copy_stub&gt;::operator()&lt;at::TensorIterator &amp; __ptr64,bool &amp; __ptr64&gt;(c10::DeviceType device_type, at::TensorIterator &amp; &lt;args_0&gt;, bool &amp; &lt;args_1&gt;) Line 74	C++
torch.dll!at::native::copy_impl(at::Tensor &amp; self, const at::Tensor &amp; src, bool non_blocking) Line 148	C++
torch.dll!at::native::copy_(at::Tensor &amp; self, const at::Tensor &amp; src, bool non_blocking) Line 157	C++
torch.dll!at::TypeDefault::copy_(at::Tensor &amp; self, const at::Tensor &amp; src, bool non_blocking) Line 1246	C++
torch.dll!c10::detail::WrapRuntimeKernelFunctor_&lt;at::Tensor &amp; __ptr64 (__cdecl*)(at::Tensor &amp; __ptr64,at::Tensor const &amp; __ptr64,bool),at::Tensor &amp; __ptr64,c10::guts::typelist::typelist&lt;at::Tensor &amp; __ptr64,at::Tensor const &amp; __ptr64,bool&gt; &gt;::operator()(at::Tensor &amp; &lt;args_0&gt;, const at::Tensor &amp; &lt;args_1&gt;, bool &lt;args_2&gt;) Line 24	C++
torch.dll!c10::detail::wrap_kernel_functor_unboxed_&lt;c10::detail::WrapRuntimeKernelFunctor_&lt;at::Tensor &amp; __ptr64 (__cdecl*)(at::Tensor &amp; __ptr64,at::Tensor const &amp; __ptr64,bool),at::Tensor &amp; __ptr64,c10::guts::typelist::typelist&lt;at::Tensor &amp; __ptr64,at::Tensor const &amp; __ptr64,bool&gt; &gt;,at::Tensor &amp; __ptr64 __cdecl(at::Tensor &amp; __ptr64,at::Tensor const &amp; __ptr64,bool)&gt;::call(c10::OperatorKernel * functor, at::Tensor &amp; &lt;args_0&gt;, const at::Tensor &amp; &lt;args_1&gt;, bool &lt;args_2&gt;) Line 261	C++
torch.dll!c10::KernelFunction::callUnboxedOnly&lt;at::Tensor &amp; __ptr64,at::Tensor &amp; __ptr64,at::Tensor const &amp; __ptr64,bool&gt;(at::Tensor &amp; &lt;args_0&gt;, const at::Tensor &amp; &lt;args_1&gt;, bool &lt;args_2&gt;) Line 95	C++
torch.dll!c10::impl::OperatorEntry::callUnboxedOnly::__l2::&lt;lambda&gt;(const c10::DispatchTable &amp; dispatchTable) Line 68	C++
torch.dll!c10::LeftRight&lt;c10::DispatchTable&gt;::read&lt;at::Tensor &amp; &lt;lambda&gt;(const c10::DispatchTable &amp;) &gt;(c10::impl::OperatorEntry::callUnboxedOnly::__l2::at::Tensor &amp; &lt;lambda&gt;(const c10::DispatchTable &amp;) &amp;&amp; readFunc) Line 74	C++
torch.dll!c10::impl::OperatorEntry::callUnboxedOnly&lt;at::Tensor &amp; __ptr64,at::Tensor &amp; __ptr64,at::Tensor const &amp; __ptr64,bool&gt;(c10::TensorTypeId dispatchKey, at::Tensor &amp; &lt;args_0&gt;, const at::Tensor &amp; &lt;args_1&gt;, bool &lt;args_2&gt;) Line 70	C++
torch.dll!c10::Dispatcher::callUnboxedOnly&lt;at::Tensor &amp; __ptr64,at::Tensor &amp; __ptr64,at::Tensor const &amp; __ptr64,bool&gt;(const c10::OperatorHandle &amp; op, c10::TensorTypeId dispatchKey, at::Tensor &amp; &lt;args_0&gt;, const at::Tensor &amp; &lt;args_1&gt;, bool &lt;args_2&gt;) Line 177	C++
torch.dll!at::Tensor::copy_(const at::Tensor &amp; src, bool non_blocking) Line 746	C++
torch.dll!torch::autograd::VariableType::copy_(at::Tensor &amp; self, const at::Tensor &amp; src, bool non_blocking) Line 151	C++
torch.dll!c10::detail::WrapRuntimeKernelFunctor_&lt;at::Tensor &amp; __ptr64 (__cdecl*)(at::Tensor &amp; __ptr64,at::Tensor const &amp; __ptr64,bool),at::Tensor &amp; __ptr64,c10::guts::typelist::typelist&lt;at::Tensor &amp; __ptr64,at::Tensor const &amp; __ptr64,bool&gt; &gt;::operator()(at::Tensor &amp; &lt;args_0&gt;, const at::Tensor &amp; &lt;args_1&gt;, bool &lt;args_2&gt;) Line 24	C++
torch.dll!c10::detail::wrap_kernel_functor_unboxed_&lt;c10::detail::WrapRuntimeKernelFunctor_&lt;at::Tensor &amp; __ptr64 (__cdecl*)(at::Tensor &amp; __ptr64,at::Tensor const &amp; __ptr64,bool),at::Tensor &amp; __ptr64,c10::guts::typelist::typelist&lt;at::Tensor &amp; __ptr64,at::Tensor const &amp; __ptr64,bool&gt; &gt;,at::Tensor &amp; __ptr64 __cdecl(at::Tensor &amp; __ptr64,at::Tensor const &amp; __ptr64,bool)&gt;::call(c10::OperatorKernel * functor, at::Tensor &amp; &lt;args_0&gt;, const at::Tensor &amp; &lt;args_1&gt;, bool &lt;args_2&gt;) Line 261	C++
torch.dll!c10::KernelFunction::callUnboxedOnly&lt;at::Tensor &amp; __ptr64,at::Tensor &amp; __ptr64,at::Tensor const &amp; __ptr64,bool&gt;(at::Tensor &amp; &lt;args_0&gt;, const at::Tensor &amp; &lt;args_1&gt;, bool &lt;args_2&gt;) Line 95	C++
torch.dll!c10::impl::OperatorEntry::callUnboxedOnly::__l2::&lt;lambda&gt;(const c10::DispatchTable &amp; dispatchTable) Line 68	C++
torch.dll!c10::LeftRight&lt;c10::DispatchTable&gt;::read&lt;at::Tensor &amp; &lt;lambda&gt;(const c10::DispatchTable &amp;) &gt;(c10::impl::OperatorEntry::callUnboxedOnly::__l2::at::Tensor &amp; &lt;lambda&gt;(const c10::DispatchTable &amp;) &amp;&amp; readFunc) Line 74	C++
torch.dll!c10::impl::OperatorEntry::callUnboxedOnly&lt;at::Tensor &amp; __ptr64,at::Tensor &amp; __ptr64,at::Tensor const &amp; __ptr64,bool&gt;(c10::TensorTypeId dispatchKey, at::Tensor &amp; &lt;args_0&gt;, const at::Tensor &amp; &lt;args_1&gt;, bool &lt;args_2&gt;) Line 70	C++
torch.dll!c10::Dispatcher::callUnboxedOnly&lt;at::Tensor &amp; __ptr64,at::Tensor &amp; __ptr64,at::Tensor const &amp; __ptr64,bool&gt;(const c10::OperatorHandle &amp; op, c10::TensorTypeId dispatchKey, at::Tensor &amp; &lt;args_0&gt;, const at::Tensor &amp; &lt;args_1&gt;, bool &lt;args_2&gt;) Line 177	C++
torch.dll!at::Tensor::copy_(const at::Tensor &amp; src, bool non_blocking) Line 746	C++
torch.dll!at::native::to_impl(const at::Tensor &amp; self, const c10::TensorOptions &amp; options, bool non_blocking) Line 25	C++
torch.dll!at::native::to(const at::Tensor &amp; self, c10::Device device, c10::ScalarType dtype, bool non_blocking, bool copy) Line 63	C++
torch.dll!at::TypeDefault::to(const at::Tensor &amp; self, c10::Device device, c10::ScalarType dtype, bool non_blocking, bool copy) Line 4830	C++
torch.dll!torch::autograd::VariableType::`anonymous namespace'::to(const at::Tensor &amp; self, c10::Device device, c10::ScalarType dtype, bool non_blocking, bool copy) Line 11390	C++
torch.dll!at::ATenOpTable::callUnboxed&lt;at::Tensor,at::Tensor const &amp; __ptr64,c10::Device,enum c10::ScalarType,bool,bool&gt;(const at::Tensor &amp; &lt;args_0&gt;, c10::Device &lt;args_1&gt;, c10::ScalarType &lt;args_2&gt;, bool &lt;args_3&gt;, bool &lt;args_4&gt;) Line 94	C++
torch.dll!at::Tensor::to(c10::Device device, c10::ScalarType dtype, bool non_blocking, bool copy) Line 3387	C++
torch.dll!torch::jit::script::module_state_to(const torch::jit::script::Slot &amp; s, const c10::optional&lt;c10::Device&gt; &amp; device, const c10::optional&lt;enum c10::ScalarType&gt; &amp; dtype, bool non_blocking) Line 123	C++
torch.dll!torch::jit::script::Module::to_impl(const c10::optional&lt;c10::Device&gt; &amp; device, const c10::optional&lt;enum c10::ScalarType&gt; &amp; dtype, bool non_blocking) Line 140	C++
torch.dll!torch::jit::script::Module::to_impl(const c10::optional&lt;c10::Device&gt; &amp; device, const c10::optional&lt;enum c10::ScalarType&gt; &amp; dtype, bool non_blocking) Line 136	C++
torch.dll!torch::jit::script::Module::to_impl(const c10::optional&lt;c10::Device&gt; &amp; device, const c10::optional&lt;enum c10::ScalarType&gt; &amp; dtype, bool non_blocking) Line 136	C++
torch.dll!torch::jit::script::Module::to(c10::Device device, bool non_blocking) Line 79	C++
</code></pre></div>
<h2 dir="auto">Expected behavior</h2>
<p dir="auto">Not to crash</p>
<h2 dir="auto">Environment</h2>
<ul dir="auto">
<li>PyTorch Version 1.3</li>
<li>Windows Version	10.0.18362 Build 18362</li>
<li>How you installed : Used the provided windows llibraries</li>
<li>CUDA/cuDNN 10.1/7</li>
<li>GPU 1060ti<br>
Visual Studio 2017 Version 15.9.8</li>
</ul>
<h2 dir="auto"><g-emoji class="g-emoji" alias="bug" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f41b.png">🐛</g-emoji> Bug</h2>

<p dir="auto">When doing inference using LibTorch in C++ for semantic segmentation on the GPU, i get the following error in debug compilation mode:</p>
<p dir="auto">cuda_dispatch_ptr INTERNAL ASSERT FAILED at C:\w\1\s\windows\pytorch\aten\src\ATen/native/DispatchStub.h:70, please report a bug to PyTorch. DispatchStub: missing CUDA kernel (operator () at C:\w\1\s\windows\pytorch\aten\src\ATen/native/DispatchStub.h:70)<br>
(no backtrace available)</p>
<p dir="auto">When I run it in release mode it does not crash and delivers the expected result. Also on the CPU, this assert is not shown.</p>
<h2 dir="auto">Environment</h2>
<ul dir="auto">
<li>PyTorch Version (e.g., 1.0): latest nightly</li>
<li>OS (e.g., Linux): WIndows 10, Visual Studio 19</li>
<li>How you installed PyTorch (<code class="notranslate">conda</code>, <code class="notranslate">pip</code>, source): downloaded prebuild libtorch</li>
<li>Build command you used (if compiling from source):</li>
<li>Python version:</li>
<li>CUDA/cuDNN version: the one included in the prebuild (cuda 10)</li>
<li>GPU models and configuration: Titan X</li>
<li>Any other relevant information:</li>
</ul>