When we are using torch.load() to load some variables or torch model, we may get this error: PytorchStreamReader failed reading zip archive: failed finding central directory. In this tutorial, we will introduce you how to fix it.
If you plan to know how to save or load a torch model, you can read:
This error looks like below:
In order to fix this error, we should add _use_new_zipfile_serialization=False when using torch.save()
torch.save(spec, spec_filename, _use_new_zipfile_serialization=False)
Then, we can use torch.load() as follows:
spec = torch.load(spec_filename)
Finally, we will find this error is fixed.