- PyTorch 1.8.0
- PyTorch 1.9.0
- PyTorch 1.11.0
Error in loading pytorch model with torch version >1.10 on ubuntu 20.04
16 ビュー (過去 30 日間)
古いコメントを表示
I'm running MATLAB R2022b on Ubuntu 20.04. I'm trying to load a pytorch model in MATLAB by running the following script:
pyenv('Version','/home/usrname/anaconda3/envs/arm/bin/python','ExecutionMode','OutOfProcess')
torch = py.importlib.import_module('torch');
a = torch.tensor([1, 2, 3, 4]);
torch.save(a, 'a.pth');
torch.load('a.pth');
However, there always exists an error:
Error using serialization>__init__
Python Error: RuntimeError: [enforce fail at inline_container.cc:120] . archive does
not contain any files
Error in serialization>load (line 777)
I made several tests and located that the error could be due to the torch version I'm using. As discussed here: https://www.mathworks.com/matlabcentral/answers/1694510-python-error-runtimeerror-enf[…]ontainer-cc-106-archive-does-not-contain-any?s_tid=srchtitle, I was using torch version 1.13.0 that caused the error. When I downgraded the torch version to 1.10, the error disappeared. However, my other scripts need to use torch version > 1.10. If there's any way can let me successfully load torch model with torch version greater than 1.10? Thank you!
2 件のコメント
Abhijeet
2023 年 3 月 9 日
Hi Yiting,
The error you encountered may be due to compatibility issues between the version of PyTorch you were using and the version of MATLAB you have.The supported versions of PyTorch for MATLAB R2022b are:
It's recommended to use one of these versions to ensure the compatibility between PyTorch and MATLAB. Using unsupported versions may lead to compatibility issues and errors.
Thanks
回答 (1 件)
Amith
2023 年 4 月 27 日
Hi,
As per your understanding you wanted to load pytorch model in matlab and are currently facing problems with the error message shown above.
The error message above suggests that there is a problem with loading a serialized object in MATLAB that was created using PyTorch 1.11.0.
Here are a few things you can try to resolve the issue:
1. Check that the serialized object file exists and is not empty. You can do this by opening the file in a text editor and verifying that it contains some data.
2. Make sure that you are using the correct version of PyTorch for your MATLAB installation. The supported versions are 1.8.0 ,1.9.0 ,1.11.0.
3. Check that you have the necessary dependencies installed for both PyTorch and MATLAB. You can refer to the documentation for both software packages to see which dependencies are required.
4. Try using a different serialization method to save the PyTorch object. For example, you can try using the `pickle` module in Python to save the object, and then load it in MATLAB using the `load` function.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Image Data Workflows についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!