An unhandled exceptionMicrosoft C ++ exception: c10 :: Error at memory location

username: Rem_H
cooked: <p>I’m trying to convert my network trained in pytorch to libtorch for inference. However, I run into this c++ exception:<br>
<code>There is an unhandled exception at 0x00007FFC58E69709 (located in cp.exe): Microsoft C ++ exception: c10 :: Error at memory location 0x0000008CF9F0F7B0.</code><br>
Here is a piece of code for testing:</p>
<pre><code class="lang-auto">#include  &lt;torch/script.h&gt; 
#include &lt;stdlib.h&gt;
#include &lt;memory&gt;
#include &lt;iostream&gt;
int main() {
	torch::jit::script::Module module = torch::jit::load("F:\ \c.pt");
	std::vector&lt;torch::jit::IValue&gt; input;
    input.push_back (torch::ones({ 36, 9, 64,64 }));
	at::Tenser output = module.forward(input).toTenser();
</code></pre>
<p>pytorch1.4 libtorch1.4  VS2019  cpu</p>
<p>why it happened?Maybe the c.pt is wrong?</p>

username: peterjc123
cooked: <p>Should be <code>“F:\\c.pt”</code>.</p>

username: Rem_H
cooked: <p>I modified it, still the same error</p>

username: peterjc123
cooked: <p>Please check the following things:</p>
<ol>
<li>All the DLLs in LibTorch are copied to the directory of the executable.</li>
<li>You are not mixing the usage of different configurations.</li>
<li>Make sure the module is saved when it is on CPU, not GPU.</li>
</ol>

username: ntatsisk
cooked: <p>I am getting exactly the same error but on a slightly different trivial example when using torchvision (C++) directly. The error appears when I try to use a VGG16 network but it works normally for a ResNet. I have submitted the issue in the torchvision repo: <a href="https://github.com/pytorch/vision/issues/2245" rel="nofollow noopener">https://github.com/pytorch/vision/issues/2245</a></p>
<p>Can anyone verify if it is related to this bug or it is on the torchvision side?</p>

username: eusouoandre
cooked: <p>I am getting exactly the same error on a totally different scenario with <code>torch.cholesky_solve</code> where on libtorch 1.4.0 I had none. I am really interested on this.<br>
Downloaded previous 1.4.0 and confirmed the problem is with 1.5.0. Trying to write minimal reproducible example to report the bug.</p>

username: eusouoandre
cooked: <p>Just solved my “bug” trying to produce the minimal reproducible example.<br>
My VStudio 2019 Project was not properly configured. I was mixing libtorch 1.4 headers with 1.5 binaries <img src="https://discuss.pytorch.org/images/emoji/apple/crazy_face.png?v=9" title=":crazy_face:" class="emoji" alt=":crazy_face:"> <img src="https://discuss.pytorch.org/images/emoji/apple/crazy_face.png?v=9" title=":crazy_face:" class="emoji" alt=":crazy_face:"> <img src="https://discuss.pytorch.org/images/emoji/apple/sweat_smile.png?v=9" title=":sweat_smile:" class="emoji" alt=":sweat_smile:"><br>
<a class="mention" href="/u/rem_h">@Rem_H</a>  I recommend you copy the configuration from the cmake project created based on the minimal example <a href="https://pytorch.org/cppdocs/installing.html#minimal-example" rel="nofollow noopener">here</a> and using the x64 native Tools Command Prompt</p>

username: Rem_H
cooked: <p>Thanks,when i tried the example c++ program like</p>
<pre><code class="lang-auto"> #include &lt;torch/torch.h&gt;
 #include
 int main() {
torch::Tensor tensor = torch::rand({ 2, 3 });
 std::cout &lt;&lt; tensor &lt;&lt; std::endl;
 return 0;
 }
</code></pre>
<p>,it’s all right,but still same wrong with load the .pt file.</p>

username: sercan
cooked: <p>It seems that loading pt file in C++ is problematical with libtorch 1.5</p>