Trying to implement pytorch in Visual Sutdio 2017

Jesper.Lindberg: <p>Hello!<br>
I have issues trying to incorprate pytorch in Visual Studio c++ Project. I got an example working with cmake, <a href="https://pytorch.org/cppdocs/installing.html#minimal-example" rel="nofollow noopener">https://pytorch.org/cppdocs/installing.html#minimal-example</a></p>
<p>However, I need to be able to incorporate it in the Visual studio Project as well. When I try to run the same Project in Visual studio, I add the following to Properties -&gt; C/C++ -&gt; Additional Include Directories:<br>
C:\Users\XX\Documents\libtorch\include\torch\csrc\api\include;<br>
C:\Users\XX\Documents\libtorch\include;%(AdditionalIncludeDirectories)<br>
and the following lib-link to Properties -&gt; Linker -&gt; Additional Library Directories:<br>
C:\Users\XX\Documents\libtorch\lib;%(AdditionalLibraryDirectories)<br>
I do not use cuda.<br>
<em><strong>When trying the stable 1.4 build I get the following problems:</strong></em></p>
<p><strong>Frist error:</strong><br>
code: E1866<br>
file: ArrayRef.h<br>
desc: attribute does not apply to an entity<br>
line: 278<br>
line 278: C10_DEFINE_DEPRECATED_USING(IntList, ArrayRef&lt;int64_t&gt;)</p>
<p><strong>Second error <em>(fixed, check replies):</em></strong><br>
code: C2872<br>
file: a lot ( check link later in the post)<br>
desc: ‘std’: ambiguous symbol</p>
<p><strong>Third error <em>(fixed):</em></strong><br>
code: C2066<br>
file: rnn.h<br>
desc: cast to function type is illegal<br>
line: 90<br>
line 90:       /<em>batch_first=</em>/bool);<br>
fix: on the forums under "C2066 error in rnn.h</p>
<p><em><strong>Using nightly build I get the following errors</strong></em></p>
<p><strong>Frist error:</strong><br>
code: E1866<br>
file: ArrayRef.h<br>
desc: attribute does not apply to an entity<br>
line: 278<br>
line 278: C10_DEFINE_DEPRECATED_USING(IntList, ArrayRef&lt;int64_t&gt;)</p>
<p><strong>Second error:</strong><br>
code:C2672<br>
desc: ‘c10::impl::boxAndCallBoxedFunc’: no matching overloaded function found	<br>
file: kernelfunction_impl.h<br>
line: 70	<br>
line 70 : return impl::boxAndCallBoxedFunc&lt;Return, Args…&gt;(boxed_kernel_func_, getFunctor_(), opHandle, std::forward(args)…);</p>
<p><strong>Third error:</strong><br>
code: C2770<br>
desc: invalid explicit template argument(s) for 'Result c10::impl::boxAndCallBoxedFunc(c10::KernelFunction::InternalBoxedKernelFunction (__cdecl *),c10::OperatorKernel *,const c10::OperatorHandle &amp;,Args…,enable_if&lt;<em>Test,<em>Ty&gt;::type)’<br>
file: kernelfunction_impl.h<br>
line: 70	<br>
line 70 : return impl::boxAndCallBoxedFunc&lt;Return, Args…&gt;(boxed_kernel_func</em>, getFunctor</em>(), opHandle, std::forward(args)…);</p>
<p><strong>Forth error:</strong><br>
code:C2893<br>
desc: Failed to specialize function template 'Result c10::impl::boxAndCallBoxedFunc(c10::KernelFunction::InternalBoxedKernelFunction (__cdecl *),c10::OperatorKernel *,const c10::OperatorHandle &amp;,Args…,enable_if&lt;<em>Test,<em>Ty&gt;::type)'file: kernelfunction_impl.h<br>
line: 70	<br>
line 70 : return impl::boxAndCallBoxedFunc&lt;Return, Args…&gt;(boxed_kernel_func</em>, getFunctor</em>(), opHandle, std::forward(args)…);</p>
<p>Any help and/or suggestions would be greatly appriciated.</p>
<p>Full error with warnings I try to compile with nightly it in VS 2017:<br>
<a href="https://paste.ofcode.org/D5hKe4FHMU3aPRbyY6BnM2" class="onebox" target="_blank" rel="nofollow noopener">https://paste.ofcode.org/D5hKe4FHMU3aPRbyY6BnM2</a></p>

G.M: <p>I got the same <code>"std": ambiguous symbol</code> error together with the C2770, C2893, C2672 using stable 1.4 with cpu.</p>

Jesper.Lindberg: <p>I was able to “fix” the std error with:</p><aside class="quote quote-modified" data-post="1" data-topic="39459">
  <div class="title">
    <div class="quote-controls"></div>
    <img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/i/91b2a8/48.png" class="avatar">
    <a href="https://discuss.pytorch.org/t/compiler-report-std-ambiguous-symbol-error-under-visual-c-2017/39459">Compiler report "'std': ambiguous symbol" error under Visual C++ 2017</a> <a class="badge-category__wrapper " href="/c/c/11"><span data-category-id="11" data-drop-close="true" class="badge-category " title="Topics related to the C++ Frontend, C++ API or C++ Extensions"><span class="badge-category__name">C++</span></span></a>
  </div>
  <blockquote>
    I download the pre-build distribution from <a href="https://pytorch.org/get-started/locally/" rel="noopener nofollow ugc">https://pytorch.org/get-started/locally/</a>(Stable-Windows-LibTorch-CUDA 10.0 version),I extract the zip file and add the inc/lib path to my VC2017 project,I write below code to test LibTorch: 
#include &lt;torch/script.h&gt; 
#include   
#include   
int main() 
{ 
std::shared_ptr<a>torch::jit::script::Module</a> model = torch::jit::load(“tmodel.pt”); 
std::cout &lt;&lt; “Hello World!\n”; 
return 0; 
} 
but compile failed,the compiler report below errors: 
Error	C2872	‘std’:…
  </blockquote>
</aside>

<p>Note that using nightly removes this error as well</p>