Hi, I’m following this tutorial to extend torch to cpp/cuda.
My setup is Ubuntu 22, Visual Code, Cuda toolkit 12.1, torch install by conda.
>>> torch.version.cuda
'12.1'
>>> torch.__version__
'2.1.0.dev20230614'
I create my cpp file as follows:
#include <torch/extension.h>
#include <cuda.h>
#include <cuda_runtime.h>
// Forward pass
// Backward pass
In .vscode/c_cpp_properties.json
, I added include path:
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/usr/local/cuda/include",
"/home/tien/anaconda3/lib/python3.9/site-packages/torch/include",
"/home/tien/anaconda3/lib/python3.9/site-packages/torch/include/torch/csrc/api/include"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c17",
"cppStandard": "gnu++17",
"intelliSenseMode": "linux-gcc-x64"
}
],
"version": 4
}
But visual code still yields an error:
How can I fix this problem?
Thanks in advance!