======================================================================
ERROR: test_serialization_filelike_api_requirements (__main__.TestTorch)
----------------------------------------------------------------------
Traceback (most recent call last):
File "test_torch.py", line 4446, in test_serialization_filelike_api_requirements
_ = torch.load(filemock)
File "C:\Users\circleci\project\build\win_tmp\build\torch\serialization.py", line 590, in load
return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
File "C:\Users\circleci\project\build\win_tmp\build\torch\serialization.py", line 754, in _legacy_load
magic_number = pickle_module.load(f, **pickle_load_args)
TypeError: file must have 'read', 'readinto' and 'readline' attributes
======================================================================
ERROR: test_serialization_filelike_missing_attrs (__main__.TestTorch)
----------------------------------------------------------------------
Traceback (most recent call last):
File "test_torch.py", line 4473, in test_serialization_filelike_missing_attrs
self._test_serialization_filelike(to_serialize, mock, desc)
File "test_torch.py", line 4458, in _test_serialization_filelike
b = torch.load(data)
File "C:\Users\circleci\project\build\win_tmp\build\torch\serialization.py", line 590, in load
return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
File "C:\Users\circleci\project\build\win_tmp\build\torch\serialization.py", line 754, in _legacy_load
magic_number = pickle_module.load(f, **pickle_load_args)
TypeError: file must have 'read', 'readinto' and 'readline' attributes
======================================================================
ERROR: test_serialization_filelike_stress (__main__.TestTorch)
----------------------------------------------------------------------
Traceback (most recent call last):
File "test_torch.py", line 4479, in test_serialization_filelike_stress
self._test_serialization_filelike(a, lambda x: FilelikeMock(x, has_readinto=False),
File "test_torch.py", line 4458, in _test_serialization_filelike
b = torch.load(data)
File "C:\Users\circleci\project\build\win_tmp\build\torch\serialization.py", line 590, in load
return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
File "C:\Users\circleci\project\build\win_tmp\build\torch\serialization.py", line 754, in _legacy_load
magic_number = pickle_module.load(f, **pickle_load_args)
TypeError: file must have 'read', 'readinto' and 'readline' attributes
----------------------------------------------------------------------
Ran 3620 tests in 103.071s
wget https://raw.githubusercontent.com/pytorch/pytorch/master/torch/utils/collect_env.py
# For security purposes, please check the contents of collect_env.py before running it.
python collect_env.py
PyTorch Version (e.g., 1.0): e4db0a5
OS (e.g., Linux): Windows
How you installed PyTorch (conda, pip, source): source
Build command you used (if compiling from source): python setup.py build
Python version: 3.8
CUDA/cuDNN version: N/A
GPU models and configuration: N/A
Any other relevant information:
Additional context
cc @ezyang @gchanan @zou3519 @peterjc123 @suo
triaged
This issue has been looked at a team member, and triaged and prioritized into an appropriate module
labels
Jan 16, 2020
I just got this problem too with Flair on Python 3.8:
state = torch.load(f, map_location=flair.device)
File "/usr/lib/python3.8/site-packages/torch/serialization.py", line 529, in load
return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
File "/usr/lib/python3.8/site-packages/torch/serialization.py", line 692, in _legacy_load
magic_number = pickle_module.load(f, **pickle_load_args)
TypeError: file must have 'read', 'readinto' and 'readline' attributes
magic_number = pickle_module.load(f, **pickle_load_args) TypeError: file must have 'read', 'readinto' and 'readline' attributes
#33232
I've created https://bugs.python.org/issue39681 as I'm not sure if this was an intentional change in CPython.
@Tpt any chance you can share a little bit more context for that error? It would be nice to know how you created f. If you can make a short example I can copy/paste and run locally that would be even better.
module: dependency bug
Problem is not caused by us, but caused by an upstream library we use
label
Feb 20, 2020
As pointed in the CPython bug report, if you're unpickling from a mmap object, it's far more efficient to do so directly from memory:
data = pickle.loads(memoryview(mmap_object))
than to issue read() calls by treating the mmap as a regular file object:
data = pickle.load(mmap_object)
The former is able to do less memory copies and also avoids indirections through the file object.
(try both on Python 3.7 and large pickled data)
Fixes #32289
This has been fixed upstream as of Python 3.8.2. I think the easiest and least invasive way to ameliorate this is to catch the error condition and print a more informative error asking the user to update their Python version. It might be possible to buffer the data into memory and then read from memory, but that would be an invasive change and might cause memory exhaustion for very large models.
Suggestions for alternate fixes or ways to improve the error message wording are very welcome.
Pull Request resolved: #33824
Differential Revision: D20131722
Pulled By: ezyang
fbshipit-source-id: a6e3fbf4bf7f9dcce5772b36f7a622cbf14b5ae4
Fixes pytorch#32289
This has been fixed upstream as of Python 3.8.2. I think the easiest and least invasive way to ameliorate this is to catch the error condition and print a more informative error asking the user to update their Python version. It might be possible to buffer the data into memory and then read from memory, but that would be an invasive change and might cause memory exhaustion for very large models.
Suggestions for alternate fixes or ways to improve the error message wording are very welcome.
Pull Request resolved: pytorch#33824
Differential Revision: D20131722
Pulled By: ezyang
fbshipit-source-id: a6e3fbf4bf7f9dcce5772b36f7a622cbf14b5ae4
* finalizes the core of framework + three models
* adds config support for train+typos fix
* fixes v3 configs modification
* pre-final trainer
* adds serve service
* adds in docker flag support
* adds granular deps install for v3 model
* adds prediction result writing function
* adds docker instructions
* adds badges
* adds LFS tracking
* adds trained models
* Revert "Trained models"
* Revert "Revert "Trained models""
* adjust v3 to eval on all data sets
* fix env var name
* adds framework coverage
* fixes model load method
* fixes prediciton to write gzip files
* final logc for server service
* final services compose files
* retrained model v3
* up lfs conf
* adds flexible abstraction for performance metrics
* adds beautify for metrics log
* fix ident
* adds readig from memory
* minor
* adjusts tests
* fixes metrics and tests
* clean up
* recalc coverage
* fix reqs
* adds fresh re-training + logs
* fix env file
* fixes pytorch unpickling issue, see
pytorch/pytorch#32289
* cleanup
* adds common entry runner script
* fixes runners
* fixes dataset class for null path to test data
* adds e2e test
* adds model param to model out path
* refactors: services unification as the 'app'
* minor: logs
* readme illustration
* refactoring
* adds extensive eval feature
* fixes dataset obj & descopes questionable feature
* cleanup
* adds evaluation service to the app
* up docu
* up readme
* cleanup trained models
* adjusts lfs tracking
* clean up
* fixes e2e test
* cleanup
* final readme
module: dependency bug
Problem is not caused by us, but caused by an upstream library we use
module: serialization
Issues related to serialization (e.g., via pickle, or otherwise) of PyTorch objects
triaged
This issue has been looked at a team member, and triaged and prioritized into an appropriate module