欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

libtorch加载模型出错:terminate called after throwing an instance of 'c10::Error'

程序员文章站 2022-07-13 23:53:58
...

libtorch加载模型出错:terminate called after throwing an instance of 'c10::Error'

引言

报错: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";