Skip to content

Potential incompatibility with v0.3 pre-trained models using weight_norm(..., dim=None) #9743

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

Closed
farleylai opened this issue Jul 24, 2018 · 2 comments
Assignees

Comments

@farleylai
Copy link

Issue description

Calling load_state_dict() to load a pre-trained PyTorch-0.3 model that uses weight_norm(..., dim=None) leads to mismatched tensor XXX_g dimension error: torch.Size([]) while torch.Size([1]) expected.

Source issue

Code example

In the weight_norm.py:

def _norm(p, dim):
    """computes the norm over all dimensions except dim"""
    if dim is None:
         return p.norm()  # returns 0-dim scalar tensor in v0.4 but 1-dim in v0.3
    ...

return p.norm().reshape(1) feels like a backward compatible workaround to return a 1-dim tensor as previous versions.

System Info

Collecting environment information...
PyTorch version: 0.4.0
Is debug build: No
CUDA used to build PyTorch: 9.1.85

OS: Ubuntu 16.04.3 LTS
GCC version: (Ubuntu 5.4.0-6ubuntu1~16.04.10) 5.4.0 20160609
CMake version: version 3.5.0

Python version: 3.6
Is CUDA available: Yes
CUDA runtime version: 9.2.148
GPU models and configuration:
GPU 0: GeForce GTX 1080 Ti
GPU 1: GeForce GTX 1080 Ti

Nvidia driver version: 396.37
cuDNN version: Probably one of the following:
/usr/lib/x86_64-linux-gnu/libcudnn.so.7.1.4

Versions of relevant libraries:
[pip3] numpy (1.13.3)
[pip3] numpydoc (0.7.0)
[pip3] torch (0.4.0)
[pip3] torchfile (0.1.0)
[pip3] torchtext (0.2.3)
[pip3] torchvision (0.2.0)
[conda] cuda80 1.0 h205658b_0 pytorch
[conda] cuda90 1.0 h6433d27_0 pytorch
[conda] cuda91 1.0 h4c16780_0 soumith
[conda] magma-cuda80 2.1.0 5 soumith
[conda] magma-cuda91 2.3.0 1 soumith
[conda] nccl2 1.0 0 soumith
[conda] pytorch 0.4.0 py36_cuda9.1.85_cudnn7.1.2_1 [cuda91] pytorch
[conda] torchfile 0.1.0
[conda] torchtext 0.2.3
[conda] torchvision 0.2.0 py36h17b6947_1 pytorch

@farleylai farleylai changed the title Potential incompatibility with v0.3 pre-trained models using weight_norm() returning a 0-dim tensor in v0.4 Potential incompatibility with v0.3 pre-trained models using weight_norm() Jul 24, 2018
@farleylai farleylai changed the title Potential incompatibility with v0.3 pre-trained models using weight_norm() Potential incompatibility with v0.3 pre-trained models using weight_norm(..., dim=None) Jul 24, 2018
jramseyer pushed a commit to jramseyer/pytorch that referenced this issue Jul 30, 2018
Summary:
This PR fixes pytorch#9743 .

Adding backward support when loading a checkpoint from 0.3.* with 1dim tensor, they are now 0 dim tensor in 0.4+.
Pull Request resolved: pytorch#9781

Differential Revision: D8988196

Pulled By: ailzhang

fbshipit-source-id: a7a1bc771d597394208430575d5a4d23b9653fef
goodlux pushed a commit to goodlux/pytorch that referenced this issue Aug 15, 2018
Summary:
This PR fixes pytorch#9743 .

Adding backward support when loading a checkpoint from 0.3.* with 1dim tensor, they are now 0 dim tensor in 0.4+.
Pull Request resolved: pytorch#9781

Differential Revision: D8988196

Pulled By: ailzhang

fbshipit-source-id: a7a1bc771d597394208430575d5a4d23b9653fef
@zhangweifeng1218
Copy link

return p.norm().reshape(1)? Is this feasible? The pytorch 0.4 has fixed the bug that pytorch 0.4 now can load the pre-trained model using weight_norm of pytorch 0.3. But When I use weight_norm in pytorch 0.4, the model still can not be trained using multiple GPUs.

@ailzhang
Copy link
Contributor

ailzhang commented Sep 5, 2018

@zhangweifeng1218 Can you provide a minimal repro script with error on multi GPUs?

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

Successfully merging a pull request may close this issue.

4 participants