-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix serialization bug #1188
Fix serialization bug #1188
Conversation
@vince62s could you review please? The diff should be straightforward. To go into some detail: I don't know a lot about Pickle, but forwarding I didn't mean to include the change in |
Well, as you say, this If you fix makes it work in all versions, we could go with it but I need full confirmation, not only Travis. For the second point, it would be better in another PR but what is the point excatly ? |
As a matter of fact I just tested your fix, it does not work on Python2.7.12
|
Oh that's not good. Let me see if I can reproduce. Are you seeing that error when you run On the second point, I felt it was cleaner but you're right that it doesn't belong here. I reverted it. |
``torchtext.Dataset.__getattr__`` is a generator. That doesn't play well with pickle. Returning a generator (when appropriate) seems to fix the issue without changing API.
I wasn't able to reproduce your error, but...
Then it should be removed. Simply commenting it out breaks Python 2 (see the end). To debug, I altered
And drilling down into pickle, we find this: So the short of it is that My solution is to override Now I pushed the change. Travis is passing. The
|
It looks like a much better fix. Thanks. double checking and merging then. |
This bug still exists! |
are you on master ? Pytorch 1.0 and torchtext 0.4 ? |
@flauted can you please check pytorch/pytorch#14893 |
Traceback (most recent call last):
File "preprocess.py", line 221, in <module>
main(opt)
File "preprocess.py", line 202, in main
'train', fields, src_reader, tgt_reader, opt)
File "preprocess.py", line 145, in build_save_dataset
torch.save(fields, vocab_path)
File "/home/aladdin/mms-hpc-devel.dynet2/lib/python2.7/site-packages/torch/serialization.py", line 219, in save
return _with_file_like(f, "wb", lambda f: _save(obj, f, pickle_module, pickle_protocol))
File "/home/aladdin/mms-hpc-devel.dynet2/lib/python2.7/site-packages/torch/serialization.py", line 144, in _with_file_like
return body(f)
File "/home/aladdin/mms-hpc-devel.dynet2/lib/python2.7/site-packages/torch/serialization.py", line 219, in <lambda>
return _with_file_like(f, "wb", lambda f: _save(obj, f, pickle_module, pickle_protocol))
File "/home/aladdin/mms-hpc-devel.dynet2/lib/python2.7/site-packages/torch/serialization.py", line 292, in _save
pickler.dump(obj)
cPickle.PicklingError: Can't pickle torch.int64: attribute lookup __main__.torch.int64 failed dude, this bug still exists in master branch!!! |
upgrade pytorch. |
This should solve the same problem as #991 . Tested against Python 2.7 and Python 3.7.