GANsNRoses icon indicating copy to clipboard operation
GANsNRoses copied to clipboard

train with smaller input size mat1 dim 1 must match mat2 dim 0

Open guitar9 opened this issue 3 years ago • 1 comments

I am using a Quadro T2000 with 4 GB Memory and tryed to train with batch size 1 and input size 128.

I get the following error:

/home/user/anaconda3/lib/python3.7/site-packages/torch/utils/cpp_extension.py:3: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative
uses
  import imp
Setting up [LPIPS] perceptual loss: trunk [vgg], v[0.1], spatial [off]
Loading model from: /home/user/anaconda3/lib/python3.7/site-packages/lpips/weights/v0.1/vgg.pth
  0%|                                                                                                                                                                           | 0/300000 [00:00<?, ?it/s]/home/user/anaconda3/lib/python3.7/site-packages/torch/nn/functional.py:3063: UserWarning: Default upsampling behavior when mode=bilinear is changed to align_corners=False since 0.4.0. Please specify align_corners=True if the old behavior is desired. See the documentation of nn.Upsample for details.
  "See the documentation of nn.Upsample for details.".format(mode))
  0%|                                                                                                                                                                           | 0/300000 [00:00<?, ?it/s]
Traceback (most recent call last):
  File "train.py", line 465, in <module>
    train(args, trainA_loader, trainB_loader, testA_loader, testB_loader, G_A2B, G_B2A, D_A, D_B, G_optim, D_optim, device)
  File "train.py", line 167, in train
    A2B_content, A2B_style = G_A2B.encode(A)
  File "/home/user/mnt/develoment/code/GANsNRoses/model.py", line 501, in encode
    return self.encoder(input)
  File "/home/user/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/user/mnt/develoment/code/GANsNRoses/model.py", line 703, in forward
    style = self.style(act)
  File "/home/user/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/user/anaconda3/lib/python3.7/site-packages/torch/nn/modules/container.py", line 117, in forward
    input = module(input)
  File "/home/user/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/user/mnt/develoment/code/GANsNRoses/model.py", line 179, in forward
    out = F.linear(input, self.weight * self.scale)
  File "/home/user/anaconda3/lib/python3.7/site-packages/torch/nn/functional.py", line 1692, in linear
    output = input.matmul(weight.t())
RuntimeError: mat1 dim 1 must match mat2 dim 0

guitar9 avatar Jul 23 '21 20:07 guitar9

For 512 and batch size 2 I changed 256 to 512, maybe with 128 it works too https://github.com/mchong6/GANsNRoses/blob/59bf4680c9c700890cdf53ffac86a6f7da8a9153/train.py#L435-L440

iszotic avatar Oct 16 '22 19:10 iszotic