Attempted to read a PyTorch file with version 3, but the maximum supported version for reading is 2. Your PyTorch installation may be too old

I tried to install the retinaface-pytorch module and execute the sample code provided there. But I run into the following error :

>>> model = get_model("resnet50_2020-07-20", max_size=2048)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/suraj/anaconda3/lib/python3.7/site-packages/retinaface/pre_trained_models.py", line 20, in get_model
    state_dict = model_zoo.load_url(models[model_name].url, progress=True, map_location="cpu")
  File "/Users/suraj/anaconda3/lib/python3.7/site-packages/torch/hub.py", line 506, in load_state_dict_from_url
    return torch.load(cached_file, map_location=map_location)
  File "/Users/suraj/anaconda3/lib/python3.7/site-packages/torch/serialization.py", line 527, in load
    with _open_zipfile_reader(f) as opened_zipfile:
  File "/Users/suraj/anaconda3/lib/python3.7/site-packages/torch/serialization.py", line 224, in __init__
    super(_open_zipfile_reader, self).__init__(torch._C.PyTorchFileReader(name_or_buffer))
RuntimeError: version_ <= kMaxSupportedFileFormatVersion INTERNAL ASSERT FAILED at ../caffe2/serialize/inline_container.cc:132, please report a bug to PyTorch. Attempted to read a PyTorch file with version 3, but the maximum supported version for reading is 2. Your PyTorch installation may be too old. (init at ../caffe2/serialize/inline_container.cc:132)
frame #0: c10::Error::Error(c10::SourceLocation, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 135 (0x1273a3787 in libc10.dylib)
frame #1: caffe2::serialize::PyTorchStreamReader::init() + 2350 (0x11b78214e in libtorch.dylib)
frame #2: caffe2::serialize::PyTorchStreamReader::PyTorchStreamReader(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 143 (0x11b78179f in libtorch.dylib)
frame #3: void pybind11::cpp_function::initialize<void pybind11::detail::initimpl::constructor<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::execute<pybind11::class_<caffe2::serialize::PyTorchStreamReader>, 0>(pybind11::class_<caffe2::serialize::PyTorchStreamReader>&)::'lambda'(pybind11::detail::value_and_holder&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >), void, pybind11::detail::value_and_holder&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, pybind11::name, pybind11::is_method, pybind11::sibling, pybind11::detail::is_new_style_constructor>(pybind11::class_<caffe2::serialize::PyTorchStreamReader>&&, void (*)(pybind11::detail::value_and_holder&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >), pybind11::name const&, pybind11::is_method const&, pybind11::sibling const&, pybind11::detail::is_new_style_constructor const&)::'lambda'(pybind11::detail::function_call&)::operator()(pybind11::detail::function_call&) const + 147 (0x11968fc13 in libtorch_python.dylib)
frame #4: pybind11::cpp_function::dispatcher(_object*, _object*, _object*) + 3372 (0x1190899fc in libtorch_python.dylib)
<omitting python frames>
frame #39: start + 1 (0x7fff707287fd in libdyld.dylib)
frame #40: 0x0 + 1 (0x1 in ???)

I do not understand this message. Any suggestions as to what I could do now, would be really appreciated.

Hi,

From the error message it seems to indicate that your current version of pytorch is too old to load this file. Which was saved with a newer version of pytorch I guess?

1 Like