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

RuntimeError: input must be contiguous #83

Open
YiingWei opened this issue Apr 29, 2023 · 2 comments
Open

RuntimeError: input must be contiguous #83

YiingWei opened this issue Apr 29, 2023 · 2 comments

Comments

@YiingWei
Copy link

YiingWei commented Apr 29, 2023

当我进行Progressive Fine-Tuning中的Stage 3: Fine-Tune DualStyleGAN on Target Domain时,输入命令:python3 -m torch.distributed.launch --nproc_per_node=2 --master_port=8765 finetune_dualstylegan.py --iter 1500 --batch 1 --ckpt ./checkpoint/generator-pretrain-003000.pt --style_loss 0.25 --CX_loss 0.25 --perc_loss 1 --id_loss 1 --L2_reg_loss 0.015 --augment cartoon
显示报错:
Traceback (most recent call last):
File "finetune_dualstylegan.py", line 539, in
train(args, loader, generator, discriminator, g_optim, d_optim, g_ema, instyles, Simgs, exstyles, vggloss, id_loss, device)
File "finetune_dualstylegan.py", line 227, in train
r1_loss = d_r1_loss(real_pred, real_img)
File "/root/DualStyleGAN-main/util.py", line 72, in d_r1_loss
outputs=real_pred.sum(), inputs=real_img, create_graph=True
File "/usr/local/lib/python3.6/dist-packages/torch/autograd/init.py", line 204, in grad
inputs, allow_unused)
File "/usr/local/lib/python3.6/dist-packages/torch/autograd/function.py", line 89, in apply
return self._forward_cls.backward(self, *args) # type: ignore
File "/root/DualStyleGAN-main/model/stylegan/op/upfirdn2d.py", line 143, in backward
ctx.out_size,
File "/root/DualStyleGAN-main/model/stylegan/op/upfirdn2d.py", line 42, in forward
g_pad_y1,
RuntimeError: input must be contiguous

请问这种情况应该怎么解决呢?

@tlsdmswn01
Copy link

I encountered a similar issue as well.
How about trying to run it with a batch size greater than 1 instead of 1?
I resolved the problem by doing so!

Translation into advanced English vocabulary:

I too have faced a comparable predicament. Have you considered executing the script with a batch size exceeding 1? I personally overcame the issue by adopting this approach!

@williamyang1991
Copy link
Owner

#39 (comment)
Here is a solution

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

3 participants