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