Problem with torch.load and torch.jit.load in Python 3.7.4 and torch 1.2.0

Mona_Jalal: <p>I am trying to load the pretrained weights from HybridPose for Linemod dataset object ape.</p>
<p>I get this error if I use torch.load:</p>
<pre><code class="lang-auto">(hp) mona@mona-ThinkStation-P7:~/HP/HybridPose$ LD_LIBRARY_PATH=lib/regressor:$LD_LIBRARY_PATH python src/train_core.py --load_dir saved_weights/linemod/ape/checkpoints/0.001/199 --object_name ape
number of model parameters: 12959563
loading checkpoint from saved_weights/linemod/ape/checkpoints/0.001/199
&gt; /home/mona/HP/HybridPose/lib/utils.py(32)load_session()
-&gt; print('Could not restore session properly, check the load_dir')
(Pdb) quit()
Traceback (most recent call last):
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/tarfile.py", line 187, in nti
    n = int(s.strip() or "0", 8)
ValueError: invalid literal for int() with base 8: 's\n_rebui'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/tarfile.py", line 2289, in next
    tarinfo = self.tarinfo.fromtarfile(self)
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/tarfile.py", line 1095, in fromtarfile
    obj = cls.frombuf(buf, tarfile.encoding, tarfile.errors)
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/tarfile.py", line 1037, in frombuf
    chksum = nti(buf[148:156])
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/tarfile.py", line 189, in nti
    raise InvalidHeaderError("invalid header")
tarfile.InvalidHeaderError: invalid header

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/site-packages/torch/serialization.py", line 555, in _load
    return legacy_load(f)
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/site-packages/torch/serialization.py", line 466, in legacy_load
    with closing(tarfile.open(fileobj=f, mode='r:', format=tarfile.PAX_FORMAT)) as tar, \
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/tarfile.py", line 1591, in open
    return func(name, filemode, fileobj, **kwargs)
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/tarfile.py", line 1621, in taropen
    return cls(name, mode, fileobj, **kwargs)
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/tarfile.py", line 1484, in __init__
    self.firstmember = self.next()
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/tarfile.py", line 2301, in next
    raise ReadError(str(e))
tarfile.ReadError: invalid header

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/mona/HP/HybridPose/lib/utils.py", line 25, in load_session
    model.load_state_dict(torch.load(os.path.join(args.load_dir, 'model.pth')))
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/site-packages/torch/serialization.py", line 386, in load
    return _load(f, map_location, pickle_module, **pickle_load_args)
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/site-packages/torch/serialization.py", line 559, in _load
    raise RuntimeError("{} is a zip archive (did you mean to use torch.jit.load()?)".format(f.name))
RuntimeError: saved_weights/linemod/ape/checkpoints/0.001/199/model.pth is a zip archive (did you mean to use torch.jit.load()?)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "src/train_core.py", line 102, in &lt;module&gt;
    model, optimizer, start_epoch = setup_model(args)
  File "src/train_core.py", line 88, in setup_model
    model, optimizer, start_epoch = load_session(model, optimizer, args)
  File "/home/mona/HP/HybridPose/lib/utils.py", line 32, in load_session
    print('Could not restore session properly, check the load_dir')
  File "/home/mona/HP/HybridPose/lib/utils.py", line 32, in load_session
    print('Could not restore session properly, check the load_dir')
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/bdb.py", line 88, in trace_dispatch
    return self.dispatch_line(frame)
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/bdb.py", line 113, in dispatch_line
    if self.quitting: raise BdbQuit
bdb.BdbQuit

</code></pre>
<p>I have</p>
<pre><code class="lang-auto">(hp) mona@mona-ThinkStation-P7:~/HP/HybridPose$ ls saved_weights/linemod/ape/checkpoints/0.001/199
total 149M
drwx------ 12 mona mona 4.0K Oct 23 15:23 ..
-rw-------  1 mona mona  50M Oct 23 15:23 model.pth
drwx------  2 mona mona 4.0K Oct 23 15:23 .
-rw-------  1 mona mona  99M Oct 23 15:23 optim.pth

</code></pre>
<p>If I use torch.jit.load:</p>
<pre><code class="lang-auto">def load_session(model, optim, args):
    try:
        start_epoch = int(args.load_dir.split('/')[-1]) + 1
        # model.load_state_dict(torch.load(os.path.join(args.load_dir, 'model.pth')))
        # optim.load_state_dict(torch.load(os.path.join(args.load_dir, 'optim.pth')))
        model.load_state_dict(torch.jit.load(os.path.join(args.load_dir, 'model.pth')))
        optim.load_state_dict(torch.jit.load(os.path.join(args.load_dir, 'optim.pth')))
        for param_group in optim.param_groups:
            param_group['lr'] = args.lr
        print('Successfully loaded model from {}'.format(args.load_dir))
    except Exception as e:
        pdb.set_trace()
        print('Could not restore session properly, check the load_dir')

    return model, optim, start_epoch
</code></pre>
<p>I have:</p>
<pre><code class="lang-auto">(hp) mona@mona-ThinkStation-P7:~/HP/HybridPose$ LD_LIBRARY_PATH=lib/regressor:$LD_LIBRARY_PATH python src/train_core.py --load_dir /home/mona/HP/HybridPose/saved_weights/linemod/ape/checkpoints/0.001/199 --object_name ape
number of model parameters: 12959563
loading checkpoint from /home/mona/HP/HybridPose/saved_weights/linemod/ape/checkpoints/0.001/199
&gt; /home/mona/HP/HybridPose/lib/utils.py(34)load_session()
-&gt; print('Could not restore session properly, check the load_dir')
(Pdb) quit()
Traceback (most recent call last):
  File "/home/mona/HP/HybridPose/lib/utils.py", line 27, in load_session
    model.load_state_dict(torch.jit.load(os.path.join(args.load_dir, 'model.pth')))
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/site-packages/torch/jit/__init__.py", line 162, in load
    cpp_module = torch._C.import_ir_module(cu, f, map_location, _extra_files)
RuntimeError: version_number &lt;= kMaxSupportedFileFormatVersion INTERNAL ASSERT FAILED at /tmp/pip-req-build-58y_cjjl/caffe2/serialize/inline_container.cc:131, please report a bug to PyTorch. Attempted to read a PyTorch file with version 3, but the maximum supported version for reading is 1. Your PyTorch installation may be too old. (init at /tmp/pip-req-build-58y_cjjl/caffe2/serialize/inline_container.cc:131)
frame #0: c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;) + 0x6d (0x7fb30d0091cd in /home/mona/anaconda3/envs/hp/lib/python3.7/site-packages/torch/lib/libc10.so)
frame #1: caffe2::serialize::PyTorchStreamReader::init() + 0x246d (0x7fb2defafe9d in /home/mona/anaconda3/envs/hp/lib/python3.7/site-packages/torch/lib/libtorch.so)
frame #2: caffe2::serialize::PyTorchStreamReader::PyTorchStreamReader(std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;) + 0x69 (0x7fb2defb1359 in /home/mona/anaconda3/envs/hp/lib/python3.7/site-packages/torch/lib/libtorch.so)
frame #3: torch::jit::import_ir_module(std::shared_ptr&lt;torch::jit::script::CompilationUnit&gt;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, c10::optional&lt;c10::Device&gt;, std::unordered_map&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::hash&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::equal_to&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt; &gt;&amp;) + 0x4d (0x7fb2e0119ddd in /home/mona/anaconda3/envs/hp/lib/python3.7/site-packages/torch/lib/libtorch.so)
frame #4: &lt;unknown function&gt; + 0x51031b (0x7fb2ff51031b in /home/mona/anaconda3/envs/hp/lib/python3.7/site-packages/torch/lib/libtorch_python.so)
frame #5: &lt;unknown function&gt; + 0x1c7126 (0x7fb2ff1c7126 in /home/mona/anaconda3/envs/hp/lib/python3.7/site-packages/torch/lib/libtorch_python.so)
&lt;omitting python frames&gt;
frame #24: &lt;unknown function&gt; + 0x29d90 (0x7fb30f629d90 in /lib/x86_64-linux-gnu/libc.so.6)
frame #25: __libc_start_main + 0x80 (0x7fb30f629e40 in /lib/x86_64-linux-gnu/libc.so.6)


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "src/train_core.py", line 102, in &lt;module&gt;
    model, optimizer, start_epoch = setup_model(args)
  File "src/train_core.py", line 88, in setup_model
    model, optimizer, start_epoch = load_session(model, optimizer, args)
  File "/home/mona/HP/HybridPose/lib/utils.py", line 34, in load_session
    print('Could not restore session properly, check the load_dir')
  File "/home/mona/HP/HybridPose/lib/utils.py", line 34, in load_session
    print('Could not restore session properly, check the load_dir')
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/bdb.py", line 88, in trace_dispatch
    return self.dispatch_line(frame)
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/bdb.py", line 113, in dispatch_line
    if self.quitting: raise BdbQuit
bdb.BdbQuit
(hp) mona@mona-ThinkStation-P7:~/HP/HybridPose$ ls /home/mona/HP/HybridPose/saved_weights/linemod/ape/checkpoints/0.001/199
total 149M
drwx------ 12 mona mona 4.0K Oct 23 15:23 ..
-rw-------  1 mona mona  50M Oct 23 15:23 model.pth
drwx------  2 mona mona 4.0K Oct 23 15:23 .
-rw-------  1 mona mona  99M Oct 23 15:23 optim.pth

</code></pre>
<p>Also, here’s the link to the repository:</p><aside class="onebox githubissue" data-onebox-src="https://github.com/chensong1995/HybridPose/issues/85">
  <header class="source">

      <a href="https://github.com/chensong1995/HybridPose/issues/85" target="_blank" rel="noopener nofollow ugc">github.com/chensong1995/HybridPose</a>
  </header>

  <article class="onebox-body">
    <div class="github-row">
  <div class="github-icon-container" title="Issue">
	  <svg width="60" height="60" class="github-icon" viewBox="0 0 14 16" aria-hidden="true"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg>
  </div>

  <div class="github-info-container">
    <h4>
      <a href="https://github.com/chensong1995/HybridPose/issues/85" target="_blank" rel="noopener nofollow ugc">using ape pretrained weight and load_dir in train_core.py </a>
    </h4>

    <div class="github-info">
      <div class="date">
        opened <span class="discourse-local-date" data-format="ll" data-date="2023-10-23" data-time="19:40:09" data-timezone="UTC">07:40PM - 23 Oct 23 UTC</span>
      </div>


      <div class="user">
        <a href="https://github.com/monajalal" target="_blank" rel="noopener nofollow ugc">
          <img alt="monajalal" src="https://avatars.githubusercontent.com/u/1892917?v=4" class="onebox-avatar-inline" width="20" height="20">
          monajalal
        </a>
      </div>
    </div>

    <div class="labels">
        <span style="display:inline-block;margin-top:2px;background-color: #B8B8B8;padding: 2px;border-radius: 4px;color: #fff;margin-left: 3px;">
          question
        </span>
    </div>
  </div>
</div>

  <div class="github-row">
    <p class="github-body-container">I get this error:
```
(hp) mona@mona-ThinkStation-P7:~/HP/HybridPose$ LD_LIBRA<span class="show-more-container"><a href="" rel="noopener" class="show-more">…</a></span><span class="excerpt hidden">RY_PATH=lib/regressor:$LD_LIBRARY_PATH python src/train_core.py --load_dir saved_weights/linemod/ape/checkpoints/0.001/199 --object_name ape
number of model parameters: 12959563
loading checkpoint from saved_weights/linemod/ape/checkpoints/0.001/199
&gt; /home/mona/HP/HybridPose/lib/utils.py(32)load_session()
-&gt; print('Could not restore session properly, check the load_dir')
(Pdb) quit()
Traceback (most recent call last):
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/tarfile.py", line 187, in nti
    n = int(s.strip() or "0", 8)
ValueError: invalid literal for int() with base 8: 's\n_rebui'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/tarfile.py", line 2289, in next
    tarinfo = self.tarinfo.fromtarfile(self)
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/tarfile.py", line 1095, in fromtarfile
    obj = cls.frombuf(buf, tarfile.encoding, tarfile.errors)
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/tarfile.py", line 1037, in frombuf
    chksum = nti(buf[148:156])
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/tarfile.py", line 189, in nti
    raise InvalidHeaderError("invalid header")
tarfile.InvalidHeaderError: invalid header

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/site-packages/torch/serialization.py", line 555, in _load
    return legacy_load(f)
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/site-packages/torch/serialization.py", line 466, in legacy_load
    with closing(tarfile.open(fileobj=f, mode='r:', format=tarfile.PAX_FORMAT)) as tar, \
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/tarfile.py", line 1591, in open
    return func(name, filemode, fileobj, **kwargs)
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/tarfile.py", line 1621, in taropen
    return cls(name, mode, fileobj, **kwargs)
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/tarfile.py", line 1484, in __init__
    self.firstmember = self.next()
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/tarfile.py", line 2301, in next
    raise ReadError(str(e))
tarfile.ReadError: invalid header

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/mona/HP/HybridPose/lib/utils.py", line 25, in load_session
    model.load_state_dict(torch.load(os.path.join(args.load_dir, 'model.pth')))
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/site-packages/torch/serialization.py", line 386, in load
    return _load(f, map_location, pickle_module, **pickle_load_args)
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/site-packages/torch/serialization.py", line 559, in _load
    raise RuntimeError("{} is a zip archive (did you mean to use torch.jit.load()?)".format(f.name))
RuntimeError: saved_weights/linemod/ape/checkpoints/0.001/199/model.pth is a zip archive (did you mean to use torch.jit.load()?)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "src/train_core.py", line 102, in &lt;module&gt;
    model, optimizer, start_epoch = setup_model(args)
  File "src/train_core.py", line 88, in setup_model
    model, optimizer, start_epoch = load_session(model, optimizer, args)
  File "/home/mona/HP/HybridPose/lib/utils.py", line 32, in load_session
    print('Could not restore session properly, check the load_dir')
  File "/home/mona/HP/HybridPose/lib/utils.py", line 32, in load_session
    print('Could not restore session properly, check the load_dir')
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/bdb.py", line 88, in trace_dispatch
    return self.dispatch_line(frame)
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/bdb.py", line 113, in dispatch_line
    if self.quitting: raise BdbQuit
bdb.BdbQuit

```

I have 
```
(hp) mona@mona-ThinkStation-P7:~/HP/HybridPose$ ls saved_weights/linemod/ape/checkpoints/0.001/199
total 149M
drwx------ 12 mona mona 4.0K Oct 23 15:23 ..
-rw-------  1 mona mona  50M Oct 23 15:23 model.pth
drwx------  2 mona mona 4.0K Oct 23 15:23 .
-rw-------  1 mona mona  99M Oct 23 15:23 optim.pth

```</span></p>
  </div>

  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>


Mona_Jalal: <p>This is very strange since I waited until the entire zip file is download and then extracted it. But author told me to check md5sum and realized it was corrupted. Re-downloaded it and used the torch.load and the problem was resolved.</p>
<aside class="onebox githubissue" data-onebox-src="https://github.com/chensong1995/HybridPose/issues/85#issuecomment-1775956590">
  <header class="source">

      <a href="https://github.com/chensong1995/HybridPose/issues/85#issuecomment-1775956590" target="_blank" rel="noopener nofollow ugc">github.com/chensong1995/HybridPose</a>
  </header>

  <article class="onebox-body">
    <div class="github-row">
  <div class="github-icon-container" title="Issue">
	  <svg width="60" height="60" class="github-icon" viewBox="0 0 14 16" aria-hidden="true"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg>
  </div>

  <div class="github-info-container">
    <h4>
      <a href="https://github.com/chensong1995/HybridPose/issues/85#issuecomment-1775956590" target="_blank" rel="noopener nofollow ugc">using ape pretrained weight and load_dir in train_core.py </a>
    </h4>

    <div class="github-info">
      <div class="date">
        opened <span class="discourse-local-date" data-format="ll" data-date="2023-10-23" data-time="19:40:09" data-timezone="UTC">07:40PM - 23 Oct 23 UTC</span>
      </div>


      <div class="user">
        <a href="https://github.com/monajalal" target="_blank" rel="noopener nofollow ugc">
          <img alt="monajalal" src="https://avatars.githubusercontent.com/u/1892917?v=4" class="onebox-avatar-inline" width="20" height="20">
          monajalal
        </a>
      </div>
    </div>

    <div class="labels">
        <span style="display:inline-block;margin-top:2px;background-color: #B8B8B8;padding: 2px;border-radius: 4px;color: #fff;margin-left: 3px;">
          question
        </span>
    </div>
  </div>
</div>

  <div class="github-row">
    <p class="github-body-container">I get this error:
```
(hp) mona@mona-ThinkStation-P7:~/HP/HybridPose$ LD_LIBRA<span class="show-more-container"><a href="" rel="noopener" class="show-more">…</a></span><span class="excerpt hidden">RY_PATH=lib/regressor:$LD_LIBRARY_PATH python src/train_core.py --load_dir saved_weights/linemod/ape/checkpoints/0.001/199 --object_name ape
number of model parameters: 12959563
loading checkpoint from saved_weights/linemod/ape/checkpoints/0.001/199
&gt; /home/mona/HP/HybridPose/lib/utils.py(32)load_session()
-&gt; print('Could not restore session properly, check the load_dir')
(Pdb) quit()
Traceback (most recent call last):
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/tarfile.py", line 187, in nti
    n = int(s.strip() or "0", 8)
ValueError: invalid literal for int() with base 8: 's\n_rebui'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/tarfile.py", line 2289, in next
    tarinfo = self.tarinfo.fromtarfile(self)
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/tarfile.py", line 1095, in fromtarfile
    obj = cls.frombuf(buf, tarfile.encoding, tarfile.errors)
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/tarfile.py", line 1037, in frombuf
    chksum = nti(buf[148:156])
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/tarfile.py", line 189, in nti
    raise InvalidHeaderError("invalid header")
tarfile.InvalidHeaderError: invalid header

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/site-packages/torch/serialization.py", line 555, in _load
    return legacy_load(f)
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/site-packages/torch/serialization.py", line 466, in legacy_load
    with closing(tarfile.open(fileobj=f, mode='r:', format=tarfile.PAX_FORMAT)) as tar, \
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/tarfile.py", line 1591, in open
    return func(name, filemode, fileobj, **kwargs)
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/tarfile.py", line 1621, in taropen
    return cls(name, mode, fileobj, **kwargs)
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/tarfile.py", line 1484, in __init__
    self.firstmember = self.next()
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/tarfile.py", line 2301, in next
    raise ReadError(str(e))
tarfile.ReadError: invalid header

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/mona/HP/HybridPose/lib/utils.py", line 25, in load_session
    model.load_state_dict(torch.load(os.path.join(args.load_dir, 'model.pth')))
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/site-packages/torch/serialization.py", line 386, in load
    return _load(f, map_location, pickle_module, **pickle_load_args)
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/site-packages/torch/serialization.py", line 559, in _load
    raise RuntimeError("{} is a zip archive (did you mean to use torch.jit.load()?)".format(f.name))
RuntimeError: saved_weights/linemod/ape/checkpoints/0.001/199/model.pth is a zip archive (did you mean to use torch.jit.load()?)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "src/train_core.py", line 102, in &lt;module&gt;
    model, optimizer, start_epoch = setup_model(args)
  File "src/train_core.py", line 88, in setup_model
    model, optimizer, start_epoch = load_session(model, optimizer, args)
  File "/home/mona/HP/HybridPose/lib/utils.py", line 32, in load_session
    print('Could not restore session properly, check the load_dir')
  File "/home/mona/HP/HybridPose/lib/utils.py", line 32, in load_session
    print('Could not restore session properly, check the load_dir')
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/bdb.py", line 88, in trace_dispatch
    return self.dispatch_line(frame)
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/bdb.py", line 113, in dispatch_line
    if self.quitting: raise BdbQuit
bdb.BdbQuit

```

I have 
```
(hp) mona@mona-ThinkStation-P7:~/HP/HybridPose$ ls saved_weights/linemod/ape/checkpoints/0.001/199
total 149M
drwx------ 12 mona mona 4.0K Oct 23 15:23 ..
-rw-------  1 mona mona  50M Oct 23 15:23 model.pth
drwx------  2 mona mona 4.0K Oct 23 15:23 .
-rw-------  1 mona mona  99M Oct 23 15:23 optim.pth

```</span></p>
  </div>

  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>


ptrblck: <pre data-code-wrap="python"><code class="lang-python">Attempted to read a PyTorch file with version 3, but the maximum supported version for reading is 1. Your PyTorch installation may be too old. 
</code></pre>
<p>You might need to update PyTorch to a newer release since <code>1.2.0</code> is quite old by now.</p>
<aside class="quote no-group" data-username="Mona_Jalal" data-post="2" data-topic="190522">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/mona_jalal/48/25715_2.png" class="avatar"> Mona_Jalal:</div>
<blockquote>
<p>Re-downloaded it and used the torch.load and the problem was resolved.</p>
</blockquote>
</aside>
<p>That’s strange, as <code>torch.jit.load</code> indicates it’s able to read the file, but it’s PyTorch version is just too old.</p>