-
Notifications
You must be signed in to change notification settings - Fork 26.5k
Closed
Labels
module: pickleProblems related to pickling of PyTorch objectsProblems related to pickling of PyTorch objectsmodule: serializationIssues related to serialization (e.g., via pickle, or otherwise) of PyTorch objectsIssues related to serialization (e.g., via pickle, or otherwise) of PyTorch objectstriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module
Description
🐛 Bug
Objects, such as lambda functions, that are supported by cloudpickle cannot be pickled with torch.save even when the user asks to use cloudpickle. torch.save calls pickle_module.Pickler, in case of cloudpickle this is the Pickler from pickle [1]!
This becomes more important when tensors cannot be pickled anymore [2].
Line 34 in eaf9b28
| warnings.warn("pickle support for Storage will be removed in 1.5. Use `torch.save` instead", FutureWarning) |
To Reproduce
import cloudpickle
import torch
data = {"foo": lambda: True}
path = "foo.pickle"
with open(path, mode="wb") as file:
cloudpickle.dump(data, file) # works
torch.save(data, path, pickle_module=cloudpickle) # failsEnvironment
$ python collect_env.py
Collecting environment information...
PyTorch version: 1.5.0
Is debug build: No
CUDA used to build PyTorch: 10.2
OS: Ubuntu 16.04.6 LTS
GCC version: (Ubuntu 9.2.1-17ubuntu1~16.04) 9.2.1 20191102
CMake version: version 3.15.1
Python version: 3.8
Is CUDA available: Yes
CUDA runtime version: 10.2.89
GPU models and configuration: GPU 0: GeForce RTX 2080 Ti
Nvidia driver version: 440.64
cuDNN version: /usr0/local/cuda-9.0/lib64/libcudnn.so.7.0.5
Versions of relevant libraries:
[pip] numpy==1.18.4
[pip] torch==1.5.0
[pip] torchvision==0.6.0a0+82fd1c8
[conda] blas 2.15 mkl conda-forge
[conda] cudatoolkit 10.2.89 hfd86e86_1
[conda] hamiltorch 0.3.1.dev3 pypi_0 pypi
[conda] libblas 3.8.0 15_mkl conda-forge
[conda] libcblas 3.8.0 15_mkl conda-forge
[conda] liblapack 3.8.0 15_mkl conda-forge
[conda] liblapacke 3.8.0 15_mkl conda-forge
[conda] mkl 2020.1 217 conda-forge
[conda] numpy 1.18.4 py38h8854b6b_0 conda-forge
[conda] pytorch 1.5.0 py3.8_cuda10.2.89_cudnn7.6.5_0 pytorch
[conda] torchvision 0.6.0 py38_cu102 pytorch
Metadata
Metadata
Assignees
Labels
module: pickleProblems related to pickling of PyTorch objectsProblems related to pickling of PyTorch objectsmodule: serializationIssues related to serialization (e.g., via pickle, or otherwise) of PyTorch objectsIssues related to serialization (e.g., via pickle, or otherwise) of PyTorch objectstriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module