Problems with Pytorch file version of reading

Lee_Shyu: <p>Tried to uninstall and reinstall several different versions from the attempted solution in other threads.</p>
<p>But still encounter this issue of not getting the “supported version for reading”.</p>
<p>Wonder if it is due to the compatibility of windows?<br>
cause it still happens even if I installed the latest version</p>
<pre><code class="lang-auto">in __init__
    super(_open_zipfile_reader, self).__init__(torch._C.PyTorchFileReader(name_or_buffer))

RuntimeError: version_ &lt;= 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)
(no backtrace available)
</code></pre>
<p>windows 10 1909 (18363.1016)</p>
<p>CPU: AMD 4800HS</p>
<p>GPU: 1650Ti</p>
<p>Pytorch version:1.4.0+cu92</p>
<p>torchvision version: 0.5.0</p>
<p>Python version: 3.7</p>
<p>Compiler: Spyder(anaconda 3)</p>
<p>import syft</p>

ptrblck: <aside class="quote no-group" data-username="Lee_Shyu" data-post="1" data-topic="100537">
<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/lee_shyu/48/29706_2.png" class="avatar"> Lee_Shyu:</div>
<blockquote>
<p>Pytorch version:1.4.0+cu92</p>
</blockquote>
</aside>
<p>The latest version is <code>1.6.0</code> at the moment and soon <code>1.7</code> so could you update it and rerun the code?</p>

Lee_Shyu: <p>Thanks.<br>
Then I updated to 1.7.0<br>
And the output becomes as below<br>
Is it due to the dependencies or compatibility?</p>
<pre><code class="lang-auto">Traceback (most recent call last):

  File "C:\Users\Lee\Downloads\HW4\Q2\federated_learning.py", line 5, in &lt;module&gt;
    from torchvision import datasets, transforms

  File "C:\Users\Lee\AppData\Roaming\Python\Python37\site-packages\torchvision\__init__.py", line 3, in &lt;module&gt;
    from torchvision import models

  File "C:\Users\Lee\AppData\Roaming\Python\Python37\site-packages\torchvision\models\__init__.py", line 12, in &lt;module&gt;
    from . import detection

  File "C:\Users\Lee\AppData\Roaming\Python\Python37\site-packages\torchvision\models\detection\__init__.py", line 1, in &lt;module&gt;
    from .faster_rcnn import *

  File "C:\Users\Lee\AppData\Roaming\Python\Python37\site-packages\torchvision\models\detection\faster_rcnn.py", line 14, in &lt;module&gt;
    from .roi_heads import RoIHeads

  File "C:\Users\Lee\AppData\Roaming\Python\Python37\site-packages\torchvision\models\detection\roi_heads.py", line 211, in &lt;module&gt;
    @torch.jit.script

  File "C:\Users\Lee\anaconda3\lib\site-packages\torch\jit\__init__.py", line 1281, in script
    fn = torch._C._jit_script_compile(qualified_name, ast, _rcb, get_default_args(obj))

  File "C:\Users\Lee\anaconda3\lib\site-packages\torch\jit\_recursive.py", line 555, in try_compile_fn
    return torch.jit.script(fn, _rcb=rcb)

  File "C:\Users\Lee\anaconda3\lib\site-packages\torch\jit\__init__.py", line 1281, in script
    fn = torch._C._jit_script_compile(qualified_name, ast, _rcb, get_default_args(obj))

  File "C:\Users\Lee\anaconda3\lib\site-packages\torch\jit\_recursive.py", line 555, in try_compile_fn
    return torch.jit.script(fn, _rcb=rcb)

  File "C:\Users\Lee\anaconda3\lib\site-packages\torch\jit\__init__.py", line 1278, in script
    ast = get_jit_def(obj)

  File "C:\Users\Lee\anaconda3\lib\site-packages\torch\jit\frontend.py", line 171, in get_jit_def
    return build_def(ctx, py_ast.body[0], type_line, self_name)

  File "C:\Users\Lee\anaconda3\lib\site-packages\torch\jit\frontend.py", line 212, in build_def
    build_stmts(ctx, body))

  File "C:\Users\Lee\anaconda3\lib\site-packages\torch\jit\frontend.py", line 127, in build_stmts
    stmts = [build_stmt(ctx, s) for s in stmts]

  File "C:\Users\Lee\anaconda3\lib\site-packages\torch\jit\frontend.py", line 127, in &lt;listcomp&gt;
    stmts = [build_stmt(ctx, s) for s in stmts]

  File "C:\Users\Lee\anaconda3\lib\site-packages\torch\jit\frontend.py", line 186, in __call__
    raise UnsupportedNodeError(ctx, node)

UnsupportedNodeError: import statements aren't supported
</code></pre>

ptrblck: <p>I haven’t seen this error before.<br>
Could you upload the file somewhere so that we could try to reproduce it, please?</p>

Lee_Shyu: <p><a href="https://drive.google.com/drive/folders/1jX9NWQVBCf0k7tu_kt3U6Ip1K0pvKsoT?usp=sharing" rel="noopener nofollow ugc">python source code</a><br>
Is it okay to share via google drive?</p>

ptrblck: <p>I would prefer if you could post it here directly or e.g. in a GitHub gist.</p>

Lee_Shyu: <p>Shared GitHub gist:<br>
</p><aside class="onebox githubgist">
  <header class="source">
      <a href="https://gist.github.com/l-shyu/bb88b77df6814b3f5e2943686f8b8fca" target="_blank" rel="noopener nofollow ugc">gist.github.com</a>
  </header>
  <article class="onebox-body">
    <h4><a href="https://gist.github.com/l-shyu/bb88b77df6814b3f5e2943686f8b8fca" target="_blank" rel="noopener nofollow ugc">https://gist.github.com/l-shyu/bb88b77df6814b3f5e2943686f8b8fca</a></h4>
<h5>Python code</h5>
<pre><code class="">import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torchvision import datasets, transforms
import syft as sy 
import random 
import sys
import os
#hook = sy.TorchHook(torch)</code></pre>
This file has been truncated. <a href="https://gist.github.com/l-shyu/bb88b77df6814b3f5e2943686f8b8fca" target="_blank" rel="noopener nofollow ugc">show original</a>

<p>
</p>

  </article>
  <div class="onebox-metadata">
    
    
  </div>
  <div style="clear: both"></div>
</aside>


ptrblck: <p>Thanks for the code. How can I reproduce this issue with it?<br>
Do I have to run it once with the <code>save</code> option and then somehow try to load it in a second run?</p>

Lee_Shyu: <p>Yeah, it will download a small part of dataset in a folder contain a folder MNIST.<br>
And after that, it should be able to train but sometime it shows the error above.</p>