Where to find <torch/torch.h>?

I succeed in compiling the code with cmake directly, but when I use vscode for editing, it always get error message with <torch/torch.h> not found. How can I get it?

Hi,

you need to add the somewhat hidden <installation dir>/include/torch/csrc/api/include to the includes.
If you create the CMakeLists.txt as in the example, the TorchConfig.cmake should set it up for you up when running find_package(Torch REQUIRED).

Best regards

Thomas

It’s works!!
Thanks!!:grinning:

Hi I am starting using Torch in c++ and I do not know what are you refering as adding the folder to the includes. Sorry if this is a very basic question.

It depends on how you compile your software.

If you use cmake you can do this in your CMakelist

find_package(Torch REQUIRED)
include_directories(SYSTEM ${TORCH_INCLUDE_DIRS})

hi, i create CMakeLists.txt as in the example and I do the configuration but appearing an error is : torch_dir not found ? what do i do for succeful compiling .