-
Notifications
You must be signed in to change notification settings - Fork 561
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Error(s) in loading state_dict for DataParallel: #27
Comments
Hi, The problem is the module is load with dataparallel activated and you are trying to load it without data parallel. That's why there's an extra module at the beginning of each key! Refer to this link for more information: |
You can also manually updated the dic. Like this:
|
The mutiple GPUs usage in pytorch is a little difficult. |
Am getting an error similar to this one
|
I suppose this issue can be closed as the referenced post mentions the cause of the error and offers a solution |
life saver! |
did you solve it please ? |
This is the solution!!!! Thanks!!!!! |
change: |
Although it will make the RuntimeError go away, don't do this unless you know what you are doing. It will leave any parameters it can't find in the checkpoint with random values. That's not what you want if the issue is caused by a mix-up of parameter names, as was the case for the issue reporter. |
Use model.module.state_dict() instead of model.state_dict() in DP mode |
When I download the pre_trained model and resume it. there is an error.
model.load_state_dict(checkpoint['state_dict'])
It seems that the name are not matched.(e.g. "module.features.0.weight" v.s. "features.module.0.weight")
How could I solve it if I wish to use the pre_trained model on Cifar10?
Thank you !
The text was updated successfully, but these errors were encountered: