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

Single-card inference #5

Open
1099255210 opened this issue May 5, 2023 · 1 comment
Open

Single-card inference #5

1099255210 opened this issue May 5, 2023 · 1 comment

Comments

@1099255210
Copy link

After training on server, I got DS-GAN-Epoch300.pth, I wanted to use this weight for single-card inference.

I changed device_ids = [0, 1, 2, 3] to device_ids = [0], and ran infer.py, then I got this error:

Traceback (most recent call last):
  File "/data/PosterLayout-CVPR2023/infer.py", line 114, in <module>
    main()
  File "/data/PosterLayout-CVPR2023/infer.py", line 111, in main
    test(G, testing_dl, 1)
  File "/data/PosterLayout-CVPR2023/infer.py", line 58, in test
    cls, box = G(imgs, fix_noise)
  File "/data/anaconda3/envs/pl/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl
    return forward_call(*input, **kwargs)
  File "/data/anaconda3/envs/pl/lib/python3.9/site-packages/torch/nn/parallel/data_parallel.py", line 166, in forward
    return self.module(*inputs[0], **kwargs[0])
  File "/data/anaconda3/envs/pl/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl
    return forward_call(*input, **kwargs)
  File "/data/PosterLayout-CVPR2023/model.py", line 99, in forward
    lstm_output = self.cnnlstm(layout, h0)
  File "/data/anaconda3/envs/pl/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl
    return forward_call(*input, **kwargs)
  File "/data/PosterLayout-CVPR2023/model.py", line 78, in forward
    output, _ = self.lstm(x, (torch.zeros_like(h0).contiguous(), h0.contiguous()))
  File "/data/anaconda3/envs/pl/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl
    return forward_call(*input, **kwargs)
  File "/data/anaconda3/envs/pl/lib/python3.9/site-packages/torch/nn/modules/rnn.py", line 767, in forward
    self.check_forward_args(input, hx, batch_sizes)
  File "/data/anaconda3/envs/pl/lib/python3.9/site-packages/torch/nn/modules/rnn.py", line 693, in check_forward_args
    self.check_hidden_size(hidden[0], self.get_expected_hidden_size(input, batch_sizes),
  File "/data/anaconda3/envs/pl/lib/python3.9/site-packages/torch/nn/modules/rnn.py", line 226, in check_hidden_size
    raise RuntimeError(msg.format(expected_hidden_size, list(hx.size())))
RuntimeError: Expected hidden[0] size (8, 4, 256), got [8, 1, 256]

Would you please try this, or offer some tips and instructions on single-card inference? Thank you!

@1099255210
Copy link
Author

Setting test_batch_size to 1 solved my problem.

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

1 participant