libtorch加载模型出错:terminate called after throwing an instance of 'c10::Error'
程序员文章站
2022-07-13 23:53:58
...
引言
报错:terminate called after throwing an instance of 'c10::Error'
solved
运行文件的路径有更改,将之前的参数传递路径直接改为绝对路径:
// const char *net_fn = getenv("***_PATH");
// net_fn = (net_fn == nullptr) ? "***.pt" : net_fn;
// module = torch::jit::load(net_fn);
module = torch::jit::load("/home/fb/XXX_SLAM2/xxx/***.pt");
if (module == nullptr) {
cout << "model load error !! " << endl;
} else cout << "Model load ok.\n";