Skip to content

visual guide for pytorch 1.0 c++ api on VS2017 (not 2018) , with no CMake (cpu only)

License

Notifications You must be signed in to change notification settings

nomoreid/visual_guide_pytorch_cpp_api_vs2018_no_cmake

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 

Repository files navigation

visual guide : pytorch c++ api (libtorch) setting on vs2017 , no CMake

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)

step 2 : unzip to some folder (ex d:\test\libtorch )

libtorch-win-shared-with-deps-latest.zip -> d:\test\libtorch folder preview

step 3 : create new c++ project on VS2017

create new project

step 4 : change project ->> win64 release <<- IMPORTANT!!!

change win64 release

  • some function (ex: torch::jit::load ) of torchlib don't work on debug conf. see ( pytorch/pytorch#15589 )

For MSVC, std::string is 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, the std::string object could not be passed into the torch library, and hence the error.

step 5 : change project setting

  1. add include directory : D:\test\libtorch\include , D:\test\libtorch\include\torch\csrc\api\include
  2. add lib : D:\test\libtorch\lib\torch.lib , D:\test\libtorch\lib\caffe2.lib , D:\test\libtorch\lib\c10.lib
  3. on c/C++ tab , "SDL checks" to "No"
  4. on c/c++ -> Language tab , "Conformance mode" to "No"

step 6 : test with some code

https://pytorch.org/cppdocs/

It works!!!

  • before execute , copy DLL files ( torch.dll , c10.dll , caffe2.dll .... )

model load toturial code ( https://pytorch.org/tutorials/advanced/cpp_export.html )

It works!!!

About

visual guide for pytorch 1.0 c++ api on VS2017 (not 2018) , with no CMake (cpu only)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published