Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

Try to include -- Always reporting error

$
0
0

I want to #include <torch/torch.h> in C++ env of VS Code.

My try

    1. 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.
    1. Also tried configure to the .vscode/c_cpp_properties.json:
"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.

    1. If only use #include <torch/torch.h> with json config

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.
    1. Tried -I with json config and absolute path include:
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.


Viewing all articles
Browse latest Browse all 12111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>