Can not load scripted model using torch::jit::load

21 views Asked by At

I use torch.jit.script to save model and using C++ to load it:

#include <torch/script.h> 
using namespace std;

int main() {
    std::string model_path = "G:/modelscriptcuda.pt";
    
   try {
    torch::jit::script::Module module = torch::jit::load(model_path, torch::kCUDA);
} catch (const c10::Error& e) {
    std::cerr << "error loading the model: " << e.what() << std::endl;
    return -1;
}}

And I got this error:

error loading the model: [enforce fail at ..\..\caffe2\serialize\inline_container.cc:197] . file not found: modelscriptcuda/version
(no backtrace available)
0

There are 0 answers