TypeError: 'DistributedDataParallel' object does not support indexing

I used LSTMCell for decoders .And my decoder module looks like this :decoders = nn.ModuleList([Decoder(args, gpu) for i in range(args.max_len)])

I changeded it for parallel using
decoders = nn.parallel.DistributedDataParallel(decoders,
device_ids=[gpu])

And when I wrote this
output = decoders [i] (input)

the error raised
TypeError: ‘DistributedDataParallel’ object does not support indexing

How can I fix this?

Hey @yhz_yhz, if you would like to access the original module that you passed to DistributedDataParallel ctor, you can use decoders.module. See the code below.