Pytorch 1.7.0版本模型转换失败

hi 我训练了一个pytorch=1.7.0版本的模型,准备转换,报版本错误,请问有最新pytorch的版本出来吗?

I Start importing pytorch…
./model/nanodet.pth ********************
Traceback (most recent call last):
File “convertpytorch.py”, line 51, in
File “convertpytorch.py”, line 41, in main
File “acuitylib/vsi_nn.py”, line 162, in load_pytorch
File “acuitylib/app/importer/import_pytorch.py”, line 92, in run
File “acuitylib/converter/convert_pytorch.py”, line 515, in init
File “torch/jit/init.py”, line 162, in load
RuntimeError: version_number <= kMaxSupportedFileFormatVersion INTERNAL ASSERT FAILED at /pytorch/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 /pytorch/caffe2/serialize/inline_container.cc:131)
frame #0: c10::Error::Error(c10::SourceLocation, std::string const&) + 0x33 (0x7f4456969273 in /home/tango/work/aml_npu_sdk_6.4.3/acuity-toolkit/bin/acuitylib/libc10.so)
frame #1: caffe2::serialize::PyTorchStreamReader::init() + 0x1e9a (0x7f44598f800a in /home/tango/work/aml_npu_sdk_6.4.3/acuity-toolkit/bin/acuitylib/libtorch.so)
frame #2: caffe2::serialize::PyTorchStreamReader::PyTorchStreamReader(std::string const&) + 0x60 (0x7f44598f9270 in /home/tango/work/aml_npu_sdk_6.4.3/acuity-toolkit/bin/acuitylib/libtorch.so)
frame #3: torch::jit::import_ir_module(std::shared_ptrtorch::jit::script::CompilationUnit, std::string const&, c10::optionalc10::Device, std::unordered_map<std::string, std::string, std::hashstd::string, std::equal_tostd::string, std::allocator<std::pair<std::string const, std::string> > >&) + 0x38 (0x7f445a9d8088 in /home/tango/work/aml_npu_sdk_6.4.3/acuity-toolkit/bin/acuitylib/libtorch.so)
frame #4: + 0x4d6abc (0x7f44a0cd9abc in /home/tango/work/aml_npu_sdk_6.4.3/acuity-toolkit/bin/acuitylib/libtorch_python.so)
frame #5: + 0x1d3f04 (0x7f44a09d6f04 in /home/tango/work/aml_npu_sdk_6.4.3/acuity-toolkit/bin/acuitylib/libtorch_python.so)

frame #28: …/bin/convertpytorch() [0x402ca1]
frame #29: …/bin/convertpytorch() [0x403087]
frame #30: __libc_start_main + 0xe7 (0x7f44d0241b97 in /lib/x86_64-linux-gnu/libc.so.6)
frame #31: …/bin/convertpytorch() [0x401a9e]

[16888] Failed to execute script convertpytorch

@111114 没有,目前支持的pytroch版本没有这么高,

请问目前pytorch支持哪个版本,或者说支持哪些版本?

@dpsfigo SDK里面有,

cat requirements.txt 
tensorflow==2.0.0
astor==0.8.0
numpy==1.18.0
scipy==1.1.0
Pillow==5.3.0
protobuf==3.11.2
networkx>=1.11
image==1.5.5
lmdb==0.93
onnx==1.6.0
h5py==2.10.0
flatbuffers==1.10
matplotlib==2.1.0
dill==0.2.8.2
ruamel.yaml==0.15.81
ply==3.11
torch==1.2.0

是不是按照文档,要在 Ubuntu 16 上安装呢?虚拟机应该是可以的吧?

@gzbigegg 我的环境是Ubuntu18,虚拟机也可以,只要能装上这些库,任何环境都是可以的

我是 Ubuntu 20 的虚拟机,直接用那个 requirements.txt 下的版本装是不行的。我按照文档换了个 Ubuntu 16,Python3.5 貌似版本低了点。我现在换个 Ubuntu 18 再试试看。

@gzbigegg python版本可以升级的,ubuntu20有一些环境包还没有支持,需要手动编译

Python3.5 可以用吗?还是说必须要升级到 3.8+ ?

@gzbigegg 没有在3.5下运行过,应该是可以的

执行第一步,好像和楼主一样的错误:

bin/convertpytorch --pytorch-model model_final.pth --net-output qcr.json --data-output qcr.data

得到下面输出

I Start importing pytorch…
model_final.pth ********************
Traceback (most recent call last):
File “convertpytorch.py”, line 51, in
File “convertpytorch.py”, line 41, in main
File “acuitylib/vsi_nn.py”, line 162, in load_pytorch
File “acuitylib/app/importer/import_pytorch.py”, line 92, in run
File “acuitylib/converter/convert_pytorch.py”, line 515, in init
File “torch/jit/init.py”, line 162, in load
RuntimeError: version_number <= kMaxSupportedFileFormatVersion INTERNAL ASSERT FAILED at /pytorch/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 /pytorch/caffe2/serialize/inline_container.cc:131)
frame #0: c10::Error::Error(c10::SourceLocation, std::string const&) + 0x33 (0x7ff723c2d273 in /media/psf/Home/Documents/OpenSource/VIM/aml_npu_sdk_6.4.3/acuity-toolkit/bin/acuitylib/libc10.so)
frame #1: caffe2::serialize::PyTorchStreamReader::init() + 0x1e9a (0x7ff726bbc00a in /media/psf/Home/Documents/OpenSource/VIM/aml_npu_sdk_6.4.3/acuity-toolkit/bin/acuitylib/libtorch.so)
frame #2: caffe2::serialize::PyTorchStreamReader::PyTorchStreamReader(std::string const&) + 0x60 (0x7ff726bbd270 in /media/psf/Home/Documents/OpenSource/VIM/aml_npu_sdk_6.4.3/acuity-toolkit/bin/acuitylib/libtorch.so)
frame #3: torch::jit::import_ir_module(std::shared_ptr < torch::jit::script::CompilationUnit>, std::string const&, c10::optional< c10::Device>, std::unordered_map< std::string, std::string, std::hash< std::string>, std::equal_to< std::string>, std::allocator<std::pair<std::string const, std::string> > >&) + 0x38 (0x7ff727c9c088 in /media/psf/Home/Documents/OpenSource/VIM/aml_npu_sdk_6.4.3/acuity-toolkit/bin/acuitylib/libtorch.so)
frame #4: + 0x4d6abc (0x7ff76df9dabc in /media/psf/Home/Documents/OpenSource/VIM/aml_npu_sdk_6.4.3/acuity-toolkit/bin/acuitylib/libtorch_python.so)
frame #5: + 0x1d3f04 (0x7ff76dc9af04 in /media/psf/Home/Documents/OpenSource/VIM/aml_npu_sdk_6.4.3/acuity-toolkit/bin/acuitylib/libtorch_python.so)

frame #28: bin/convertpytorch() [0x402ca1]
frame #29: bin/convertpytorch() [0x403087]
frame #30: __libc_start_main + 0xe7 (0x7ff79d544bf7 in /lib/x86_64-linux-gnu/libc.so.6)

Ubuntu 18.04 Desktop
Python 3.6
所有软件包的版本都是按照 requirements.txt 里面来的。

请问是我的模型文件版本太高或者太低的问题吗?怎么解决?

@gzbigegg 建议使用和SDK支持版本一样的版本

是我的模型要是pytorch1.2版本上的吗?还是说我在模型转换时电脑上要是1.2版本的pytorch

@luleibo 都要的,你1.7训练出来的模型,在1.2环境下是打不开的。