Skip to content
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

The model used contains deepcopy, and a TypeError: cannot pickle 'MinkowskiConvolutionFunction' object error was reported when using this project #27

Open
Joker9194 opened this issue Feb 7, 2023 · 1 comment

Comments

@Joker9194
Copy link

Describe the bug
I installed it according to the installation steps. I used ema in my project, which used deepcopy code, and this error occurred when the project was running.
“TypeError: cannot pickle 'MinkowskiConvolutionFunction' object”

Expected behavior
The project is running normally

Desktop (please complete the following information):

OS: [e.g. Ubuntu 18.04]
Python version: [e.g. 3.8.13]
Pytorch version: [e.g. 1.10.1]
CUDA version: [e.g. 11.3]
NVIDIA Driver version: [e.g. 510.60]
Minkowski Engine version [e.g. 0.5.4]

@blackpearl1022
Copy link

import copy
import torch
from torch.nn import Module

class CustomModel(Module):
    def __init__(self):
        super(CustomModel, self).__init__()
        # Initialize your model components here

    def __deepcopy__(self, memo):
        # Create a new instance of your model
        new_instance = type(self)()
        memo[id(self)] = new_instance
        
        # Copy the state_dict of the original model to the new instance
        new_instance.load_state_dict(copy.deepcopy(self.state_dict(), memo))
        
        return new_instance

# Example usage
model = CustomModel()
ema_model = copy.deepcopy(model)

model = CustomModel()
ema_model = CustomModel()
ema_model.load_state_dict(copy.deepcopy(model.state_dict()))

Try this one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants