visual guide for pytorch 1.0 c++ api on VS2017 , with no CMake (cpu only)
step 1 : download libtorch on https://pytorch.org/
stable -> windows -> libtorch -> c++ -> None(cpu only)
libtorch-win-shared-with-deps-latest.zip -> d:\test\libtorch
- some function (ex: torch::jit::load ) of torchlib don't work on debug conf. see ( pytorch/pytorch#15589 )
For MSVC,
std::stringis not defined the same for the configurations Debug and Release. Since we built libtorch with the Release configuration, if you try to use the Debug configuration when compiling the executable, thestd::stringobject could not be passed into the torch library, and hence the error.
- add include directory : D:\test\libtorch\include , D:\test\libtorch\include\torch\csrc\api\include
- add lib : D:\test\libtorch\lib\torch.lib , D:\test\libtorch\lib\caffe2.lib , D:\test\libtorch\lib\c10.lib
- on c/C++ tab , "SDL checks" to "No"
- on c/c++ -> Language tab , "Conformance mode" to "No"
It works!!!
model load toturial code ( https://pytorch.org/tutorials/advanced/cpp_export.html )







