-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Closed
Labels
Description
🐛 Bug
When pickling a torch.dtype object, Python 3.5 reports an obscure error "can't pickle int objects".
To Reproduce
Steps to reproduce the behavior:
In [1]: import torch
In [2]: import pickle
In [3]: with open('/tmp/a', 'wb') as f:
...: pickle.dump(torch.float32, f)
...:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-3-769b4901f38c> in <module>()
1 with open('/tmp/a', 'wb') as f:
----> 2 pickle.dump(torch.float32, f)
3
~/anaconda3/envs/tmp/lib/python3.5/copyreg.py in _reduce_ex(self, proto)
63 else:
64 if base is self.__class__:
---> 65 raise TypeError("can't pickle %s objects" % base.__name__)
66 state = base(self)
67 args = (self.__class__, base, state)
TypeError: can't pickle int objectsExpected behavior
In Python 3.6 one can pickle torch dtypes successfully.
Environment
Collecting environment information...
PyTorch version: 0.4.1.post2
Is debug build: No
CUDA used to build PyTorch: 9.0.176
OS: Fedora release 29 (Twenty Nine)
GCC version: (GCC) 8.2.1 20181011 (Red Hat 8.2.1-4)
CMake version: version 3.12.1
Python version: 3.5
Is CUDA available: Yes
CUDA runtime version: 9.2.148
GPU models and configuration: GPU 0: GeForce GTX 1070
Nvidia driver version: 410.73
cuDNN version: Could not collect
Versions of relevant libraries:
[pip] numpy (1.15.2)
[pip] torch (0.4.1.post2)
[conda] pytorch 0.4.1 py35_py27__9.0.176_7.1.2_2 pytorch