Trying to implement pytorch in Visual Sutdio 2017

Hello!
I have issues trying to incorprate pytorch in Visual Studio c++ Project. I got an example working with cmake, https://pytorch.org/cppdocs/installing.html#minimal-example

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 -> C/C++ -> Additional Include Directories:
C:\Users\XX\Documents\libtorch\include\torch\csrc\api\include;
C:\Users\XX\Documents\libtorch\include;%(AdditionalIncludeDirectories)
and the following lib-link to Properties -> Linker -> Additional Library Directories:
C:\Users\XX\Documents\libtorch\lib;%(AdditionalLibraryDirectories)
I do not use cuda.
When trying the stable 1.4 build I get the following problems:

Frist error:
code: E1866
file: ArrayRef.h
desc: attribute does not apply to an entity
line: 278
line 278: C10_DEFINE_DEPRECATED_USING(IntList, ArrayRef<int64_t>)

Second error (fixed, check replies):
code: C2872
file: a lot ( check link later in the post)
desc: ‘std’: ambiguous symbol

Third error (fixed):
code: C2066
file: rnn.h
desc: cast to function type is illegal
line: 90
line 90: /batch_first=/bool);
fix: on the forums under "C2066 error in rnn.h

Using nightly build I get the following errors

Frist error:
code: E1866
file: ArrayRef.h
desc: attribute does not apply to an entity
line: 278
line 278: C10_DEFINE_DEPRECATED_USING(IntList, ArrayRef<int64_t>)

Second error:
code:C2672
desc: ‘c10::impl::boxAndCallBoxedFunc’: no matching overloaded function found
file: kernelfunction_impl.h
line: 70
line 70 : return impl::boxAndCallBoxedFunc<Return, Args…>(boxed_kernel_func_, getFunctor_(), opHandle, std::forward(args)…);

Third error:
code: C2770
desc: invalid explicit template argument(s) for 'Result c10::impl::boxAndCallBoxedFunc(c10::KernelFunction::InternalBoxedKernelFunction (__cdecl *),c10::OperatorKernel *,const c10::OperatorHandle &,Args…,enable_if<Test,Ty>::type)’
file: kernelfunction_impl.h
line: 70
line 70 : return impl::boxAndCallBoxedFunc<Return, Args…>(boxed_kernel_func
, getFunctor
(), opHandle, std::forward(args)…);

Forth error:
code:C2893
desc: Failed to specialize function template 'Result c10::impl::boxAndCallBoxedFunc(c10::KernelFunction::InternalBoxedKernelFunction (__cdecl *),c10::OperatorKernel *,const c10::OperatorHandle &,Args…,enable_if<Test,Ty>::type)'file: kernelfunction_impl.h
line: 70
line 70 : return impl::boxAndCallBoxedFunc<Return, Args…>(boxed_kernel_func
, getFunctor
(), opHandle, std::forward(args)…);

Any help and/or suggestions would be greatly appriciated.

Full error with warnings I try to compile with nightly it in VS 2017:
https://paste.ofcode.org/D5hKe4FHMU3aPRbyY6BnM2

2 Likes

I got the same "std": ambiguous symbol error together with the C2770, C2893, C2672 using stable 1.4 with cpu.

I was able to “fix” the std error with:

Note that using nightly removes this error as well

1 Like