I want to #include <torch/torch.h>
in C++ env of VS Code.
My try
- I tried to use absolute include path:
#include <C:/Users/Felix/AppData/Local/Programs/Python/Python310/Lib/site-packages/torch/include/torch/csrc/api/include/torch/torch.h>
But got error:
In file included from try.cpp:6:C:/Users/Felix/AppData/Local/Programs/Python/Python310/Lib/site-packages/torch/include/torch/csrc/api/include/torch/torch.h:3:10: fatal error: torch/all.h: No such file or directory #include <torch/all.h> ^~~~~~~~~~~~~compilation terminated.
- Also tried configure to the
.vscode/c_cpp_properties.json
:
- Also tried configure to the
"includePath": ["${workspaceFolder}/**","C:/Users/Felix/AppData/Local/Programs/Python/Python310/Lib/site-packages/torch/include/torch/csrc/api/include","D:/develop/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include","D:/develop/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include-fixed"]
Still got the same error.
- If only use
#include <torch/torch.h>
with json config
- If only use
Got error:
PS D:\VS CODE\FlashAttentionV2> cd "d:\VS CODE\FlashAttentionV2\" ; if ($?) { g++ try.cpp -o try } ; if ($?) { .\try }try.cpp:6:10: fatal error: torch/torch.h: No such file or directory #include <torch/torch.h> ^~~~~~~~~~~~~~~compilation terminated.
- Tried
-I
with json config and absolute path include:
- Tried
PS D:\VS CODE\FlashAttentionV2> g++ -I "C:\Users\Felix\AppData\Local\Programs\Python\Python310\Lib\site-packages\torch\include\torch\" try.cpp
Got same error in 1.
My system
My code runs in windows 11:
AMD Ryzen 7 5800H with Radeon Graphics 3.20 GH
- OS:
22631.3593
My file locate in D:\VS CODE\FlashAttentionV2\try.cpp
I tried to google these things, but didn't find more solutions. If you can help me to figure what to do next, thank you very much!!
I have included these things in the details of the problem.