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

TypeError: upfirdn2d() takes from 2 to 8 positional arguments but 10 were given #11

Open
picard314 opened this issue Jul 24, 2023 · 4 comments

Comments

@picard314
Copy link

Dear Author,

I encountered this in running

python3 train.py --batch 3 --ckpt pretrained/tdmm_lizhen_full.pt --mode 3 path_to_dataset

I have installed stylegan_ops with logs looking fine.

I shall be most grateful if you may look into this. Thanks!

Sincerely,
Picard

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

logs in detail:

Traceback (most recent call last):
File "/mnt/swh/git/StyleAvatar/styleunet/train.py", line 340, in
train(args, loader, generator, discriminator, g_ema, g_optim, d_optim, device)
File "/mnt/swh/git/StyleAvatar/styleunet/train.py", line 147, in train
fake_img = generator(cond_img, latent)
File "/home/rtcai3/anaconda3/envs/geneface/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl
return forward_call(*input, **kwargs)
File "/mnt/swh/git/StyleAvatar/styleunet/networks/generator.py", line 91, in forward
cond_img = self.dwt(condition_img)
File "/home/rtcai3/anaconda3/envs/geneface/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl
return forward_call(*input, **kwargs)
File "/mnt/swh/git/StyleAvatar/styleunet/networks/modules.py", line 397, in forward
ll = upfirdn2d(input, self.ll, down=2)
File "/mnt/swh/git/StyleAvatar/styleunet/networks/stylegan2_ops/upfirdn2d.py", line 165, in upfirdn2d
out = UpFirDn2d.apply(input, kernel, up, down, pad)
File "/mnt/swh/git/StyleAvatar/styleunet/networks/stylegan2_ops/upfirdn2d.py", line 121, in forward
out = upfirdn2d_op.upfirdn2d(
TypeError: upfirdn2d() takes from 2 to 8 positional arguments but 10 were given

@LizhenWangT
Copy link
Owner

Please check the shape of cond_img, it should be (batch, 3, 256, 256)

@picard314
Copy link
Author

Please check the shape of cond_img, it should be (batch, 3, 256, 256)

Thanks very much for your reply~ I've printed the shape of cond_img and it is "torch.Size([3, 3, 256, 256])". Any more information please~?

@LizhenWangT
Copy link
Owner

Any more information or someone else can reproduce this problem? I can not reproduce this bug, Orz. It seems you are using the geneface's env. Maybe there are some conflicts?

@picard314
Copy link
Author

picard314 commented Jul 24, 2023

Thanks very much for your informations.

I just used your

from torch.utils.cpp_extension import load
module_path = os.path.dirname(file)
upfirdn2d_op = load(
"upfirdn2d",
sources=[
os.path.join(module_path, "upfirdn2d.cpp"),
os.path.join(module_path, "upfirdn2d_kernel.cu"),
],
)

instead of

import upfirdn2d as upfirdn2d_op

and it worked.

I use another env since my server does not support CUDA 11.7. But I guess env may be not the point. Could you please show me your ninja version? Mine is ninja 1.11.1. If compiled upfirdn2d does not have enough advantage on saving training time, I choose source code instead.

Cheers for your wonderful work~

Sincerely,
Picard

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

2 participants