Cannot load tensor saved by -- PytorchStreamReader failed reading zip archive: not a ZIP archive


I cannot load a tensor saved with pytorch in cpp. I am getting the following error:

terminate called after throwing an instance of 'c10::Error'
  what():  [enforce fail at] . PytorchStreamReader failed reading zip archive: not a ZIP archive
frame #0: c10::ThrowEnforceNotMet(char const*, int, char const*, std::string const&, void const*) + 0x47 (0x7f39e02e76a7 in /opt/project_cpp/test/include/libtorch/lib/
frame #1: caffe2::serialize::PyTorchStreamReader::valid(char const*, char const*) + 0x8b (0x7f39be4f272b in /opt/project_cpp/test/include/libtorch/lib/
frame #2: caffe2::serialize::PyTorchStreamReader::init() + 0x9e (0x7f39be4f4a9e in /opt/project_cpp/test/include/libtorch/lib/
frame #3: caffe2::serialize::PyTorchStreamReader::PyTorchStreamReader(std::unique_ptr<caffe2::serialize::ReadAdapterInterface, std::default_delete<caffe2::serialize::ReadAdapterInterface> >) + 0x57 (0x7f39be4f7527 in /opt/project_cpp/test/include/libtorch/lib/
frame #4: torch::jit::pickle_load(std::vector<char, std::allocator<char> > const&) + 0xa3 (0x7f39bf7c07d3 in /opt/project_cpp/test/include/libtorch/lib/
frame #5: torch::pickle_load(std::vector<char, std::allocator<char> > const&) + 0x9 (0x7f39bfa27df9 in /opt/project_cpp/test/include/libtorch/lib/
frame #6: <unknown function> + 0x6e10 (0x560f66cbce10 in ./trt_sample)
frame #7: <unknown function> + 0x8019 (0x560f66cbe019 in ./trt_sample)
frame #8: __libc_start_main + 0xe7 (0x7f397ea80b97 in /lib/x86_64-linux-gnu/
frame #9: <unknown function> + 0x64da (0x560f66cbc4da in ./trt_sample)

I reinstalled LibTorch with cuda (Pre-cxx11 ABI & cxx11 ABI) but still not working.
I can use the torch library normally, but cannot load models/tensors/dicts saved with

Code to load .pt file:

torch::IValue loadPytorchTensor(string fname) {
  std::ifstream input_stream(fname);
  input_stream >> std::noskipws;
  std::vector<char> input;
  cout << "Before -----"  << endl; //Prints as expected
  torch::IValue ivalue = torch::pickle_load(input);
  cout << "After  -----" << endl; // Currently this never prints 

  return ivalue;

  string tensor_fn =  "";
  torch::IValue ivalue = loadPytorchTensor(tensor_fn);


The rig I am getting the error on has GeForce RTX 2060.
I ran the same code and tried to load the same file on a pc having a GeForce RTX 2080 Ti and it worked properly.

Issue was resolved. The path to the file was incorrect! This dir location confusion was because of working in the docker env. Mounting the correct folder solved the problem.

The error message not a ZIP archive is misleading though. It is better to add a more comprehensive and specified message like File not found or wrong path.