Setting Visual Studio for Pytorch C++

Khushi Agrawal 1 Reputation point
2021-05-29T16:41:36.123+00:00

I'm trying to set visual studio for pytorch in cpp language but I'm getting the following error

Build started...
1>------ Build started: Project: ConsoleApplication1, Configuration: Debug x64 ------
1>ConsoleApplication1.cpp
1>C:\Users\91939\source\repos\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.cpp(1,10): fatal error C1083: Cannot open include file: 'torch\torch.h': No such file or directory
1>Done building project "ConsoleApplication1.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Please help me out to resolve the error.

I used

https://raminnabati.com/post/004_adv_pytorch_integrating_pytorch_cpp_frontend_in_visual_studio_on_windows/

this blog for setting up the environment for visual studio.

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,540 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Sam of Simple Samples 5,516 Reputation points
    2021-05-29T17:34:15.803+00:00

    Did you set the environment variables as described in Step 2? I hope you did not install LibTorch to C:\libtorch-debug-v1.5.1; I would have installed it to a subdirectory someplace.

    As described in Step 3, in Project Properties under C/C++ -> General -> Additional Include Directories, did you add the path to LibTorch? If not then the compiler does not know where torch\torch.h is.

    1 person found this answer helpful.

  2. Yi Zhang 1 Reputation point Microsoft Employee
    2021-11-23T03:01:57.887+00:00

    You could try https://marketplace.visualstudio.com/items?itemName=YiZhang.LibTorch001.
    IIt will help you setup LibTorch Visual studio Project automatically.

    0 comments No comments