StoryGAN icon indicating copy to clipboard operation
StoryGAN copied to clipboard

AttributeError: 'function' object has no attribute 'parameters' for `nn.parallel.data_parallel`

Open zyong812 opened this issue 4 years ago • 11 comments

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!

zyong812 avatar Jul 15 '19 04:07 zyong812

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.

yitong91 avatar Jul 15 '19 04:07 yitong91

OK, thank you

zyong812 avatar Jul 15 '19 05:07 zyong812

Hello! I have the same problem. Can you tell me how to set only 1 GPU? Thank you!

EdmundYanJ avatar Sep 19 '19 13:09 EdmundYanJ

I think, in the config file, just set one GPU id. Or you should read source codes more carefully.

zyong812 avatar Sep 21 '19 15:09 zyong812

OK! Thank you. I would modify the config file and test.

EdmundYanJ avatar Sep 22 '19 07:09 EdmundYanJ

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!

epejhan90 avatar Oct 10 '19 14:10 epejhan90

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.

yitong91 avatar Oct 10 '19 16:10 yitong91

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

sunshinemingo avatar Nov 01 '19 15:11 sunshinemingo

I met the same problem with you , can you tell me how you solved the problem? Thanks a lot! @EdmundYanJ

sunshinemingo avatar Nov 07 '19 01:11 sunshinemingo

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?

yiyayamaya avatar Dec 06 '19 15:12 yiyayamaya

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)

yiyayamaya avatar Dec 06 '19 16:12 yiyayamaya