When I use dataparallelism on my model I can no longer call defined method within the model, how I can remedy this?

(Inkplay) #1

I have a 2 GPUs so I want to use data parallelism. In my prototype I build a method within the model itself so I can call model.dosomething(), this works if I only use 1 gpu E.g. using model.cuda(). Now that my model is done testing I want to utilize the power of 2 GPUs. I can no longer do model.dosomething() because model is now a type of <class 'torch.nn.parallel.data_parallel.DataParallel'>. How can I remedy this beside rewrite the entire model again?

(Juan F Montesinos) #2

Do model.module.something()