importing matlab.engine breaks pytorch-lightning model loading.
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Domain
- machine-learning
Research direction
Start with the minimal reproduction using matlab.engine before the LITModel import and inspect pytorch_lightning/core/saving.py, utilities/cloud_io.py, and torch/serialization.py at the traceback locations. Compare behavior with the imports reversed and verify the reported Python, PyTorch, PyTorch Lightning, MATLAB Engine, and Ubuntu versions. Done means the checkpoint loads successfully regardless of import order, or the compatibility limitation is clearly documented.
Written by the indexing model from the issue text.
Description
It's difficult to assess what package is causing the issue, but i'm going to raise it here as this issue only happens when matlab.engine is imported.
Bug description
importing matlab.engine breaks pytorch_lightning ability to load a previously saved model.
This only happens when import matlab.engine is included in the script. The checkpoint_path is not empty.
How to reproduce the bug
import matlab.engine
from my_custom_model import LITModel # this is a pytorch_lightning.LightningModule model
chkpoint_path = '/path/to/my/checkpoint.ckpt'
model = LITModel.load_from_checkpoint(checkpoint_path=chkpoint_path)
Important
- If the import of
matlab.enginecomes after theLITModelimport, then the code does not error.
Error messages and logs
LITModel.load_from_checkpoint(chkpoint_path)
File "/home/anaconda3/envs/torch/lib/python3.8/site-packages/pytorch_lightning/core/saving.py", line 139, in load_from_checkpoint
checkpoint = pl_load(checkpoint_path, map_location=lambda storage, loc: storage)
File "/home/anaconda3/envs/torch/lib/python3.8/site-packages/pytorch_lightning/utilities/cloud_io.py", line 47, in load
return torch.load(f, map_location=map_location)
File "/home/anaconda3/envs/torch/lib/python3.8/site-packages/torch/serialization.py", line 705, in load
with _open_zipfile_reader(opened_file) as opened_zipfile:
File "/home/anaconda3/envs/torch/lib/python3.8/site-packages/torch/serialization.py", line 243, in __init__
super(_open_zipfile_reader, self).__init__(torch._C.PyTorchFileReader(name_or_buffer))
RuntimeError: [enforce fail at inline_container.cc:106] . archive does not contain any files
Environment
- Linux: Ubuntu 22.04.1 LTS
- python==3.8.12
- pytorch_lightning==1.6.4
- torch==1.11.0
- matlabengine==9.13.1
- Matlab: R2022b
- Dominant language
- Python
- Stars
- 97
- Forks
- 13
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from mathworks/matlab-engine-for-python
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
-
Difficulty 3/5 1-2 days Newbie friendliness 38/100
-
Support sparse array Open
Difficulty 4/5 3-5 days Newbie friendliness 42/100
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
All issues in mathworks/matlab-engine-for-python
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
qgis/QGIS-Documentation#11275 ·
-
bug priority:normal ready-for-dev
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
OpenHands/extensions#626 · 1 comment ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
CSCfi/sd-search-api#39 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
StevenBlack/hosts#3255 ·