'DistributedDataParallel' object has no attribute 'my_custom_method'

I had run my command on Terminal as below
$ python -m torch.distributed.run --nproc_per_node=2 train_ddp.py

and in my code, I had used “module” attribute before accessing my_custom_method like below
“out = model.module.my_custom_method”
but looked like that DDP still can not access my custom method. The error was shown as below

==> ‘DistributedDataParallel’ object has no attribute ‘my_custom_method’

Please help to advise. Thanks.

Could you share a code snippet that can reproduce the error?

Hi Andrew, thanks… I resolved my problem. Thanks…