出现这个错误的原因是:terminate called after throwing an instance of 'c10::Error'。解答:下面三个.json里面libtorch和build的路径没有给对,是路径错误
tasks.json
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "example-app", //lauch.json preLaunchTask
"command": "cmake",
"args": [
"-DCMAKE_PREFIX_PATH=/home/zxw/Documents/work/libtorch-shared-with-deps-1.7.0/libtorch",
"-DCMAKE_BUILD_TYPE=Debug",
"..",
"&&",
"make",
"-j",
],
"options": {
"cwd": "/home/zxw/Documents/work/libtorch-shared-with-deps-1.7.0/example-app/build"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) 启动",
"type": "cppdbg",
"request": "launch",
"program": "/home/zxw/Documents/work/libtorch-shared-with-deps-1.7.0/example-app/build/example-app",
"args": [],
"stopAtEntry": false,
"cwd": "/home/zxw/Documents/work/libtorch-shared-with-deps-1.7.0/example-app/build",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "example-app",
"miDebuggerPath": "/usr/bin/gdb",
}
]
}
c_cpp_properties.json
{
"configurations": [
{
"name": "Linux",
"includePath": [
"/home/zxw/Documents/work/libtorch-shared-with-deps-1.7.0/example-app/build/**",
"/home/zxw/Documents/work/libtorch-shared-with-deps-1.7.0/libtorch/**"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "gnu11",
"cppStandard": "c++17",
"intelliSenseMode": "gcc-x64"
}
],
"version": 4
}