StoryGAN
StoryGAN copied to clipboard
AttributeError: 'function' object has no attribute 'parameters' for `nn.parallel.data_parallel`
Dear author,
It seems these codes don't work for multiple GPUs.
nn.parallel.data_parallel(netG.sample_videos, st_inputs, self.gpus)
nn.parallel.data_parallel(netG.sample_images, im_inputs, self.gpus)
It prompts AttributeError: 'function' object has no attribute 'parameters'
. (There is no problem if I only set 1 GPU.)
I have also checked PyTorch docs at https://pytorch.org/docs/stable/_modules/torch/nn/parallel/data_parallel.html.
It seems that the first argument for nn.parallel.data_parallel
should be a module, instead of a function.
Have you encountered this problem? Thank you!
The code has not been tested for multiple GPU. Actually, the first parameter should be a module with 'forward' function, as in standard pytorch layers. However, we changed the model to have both image generator and story generator, this part is not usable anymore. I will clean it up.
OK, thank you
Hello! I have the same problem. Can you tell me how to set only 1 GPU? Thank you!
I think, in the config file, just set one GPU id. Or you should read source codes more carefully.
OK! Thank you. I would modify the config file and test.
Hi, I have the same problem. I set "1" for GPU_ID in config file but it doesn't work. And which part can be cleaned up exactly? Thanks!
I remember that this is because we need a forward() function to support the multi-gpu config. However, the current implementation has one image and one story generator, we need two forward() functions (one for each) in the same class and this is obviously not allowed. I'm not sure if there is an easy way to fix it.
Hello, I set GPU id:'0' in the config file, but I still met the same error, can you tell me how to solve the problem? Thanks a lot! @yitong91 @zyong812
I met the same problem with you , can you tell me how you solved the problem? Thanks a lot! @EdmundYanJ
I met the same problem with you , can you tell me how you solved the problem? Thanks a lot! @EdmundYanJ
Hi ! I met this problem,too. Have you solved it?
Hi! There is a solution https://www.twblogs.net/a/5d42bb23bd9eee51fbf9eacf/zh-cn.
modify some lines in trainer.py
remove
im_inputs = (im_motion_input, im_content_input)
_, im_fake, im_mu, im_logvar = \
nn.parallel.data_parallel(netG.sample_images, im_inputs, self.gpus)
st_inputs = (st_motion_input, st_content_input)
_, st_fake, c_mu, c_logvar, m_mu, m_logvar = \
nn.parallel.data_parallel(netG.sample_videos, st_inputs, self.gpus)
`
add _, im_fake, im_mu, im_logvar =netG.sample_images( im_motion_input, im_content_input)
_, st_fake, c_mu, c_logvar, m_mu, m_logvar=netG.sample_videos( st_motion_input, st_content_input)