# Python 3.6
# Pytorch 4.1 installed via anaconda
import torch
from torch import nn

class Net(nn.Module):
    def __init__(self):
        super(Net, self).__init__()
        self.module_list = nn.ModuleList()
        self.module_list.append(nn.Linear(2, 2))
        self.module_list.append(nn.Linear(2, 2))
    
    def parameters(self, only_trainable=True):
        for param in self.module_list.parameters():
            if only_trainable and not param.requires_grad:
                continue
            yield param
    
    def forward(self, x):
        return x

net = Net().cuda()
for p in net.module_list[0].parameters():
    p.requires_grad = False
net = nn.DataParallel(net, [0, 1])
net(torch.rand(10, 2))

Produces the same error
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-3-dc513201071a> in <module>()
     24     p.requires_grad = False
     25 net = nn.DataParallel(net, [0, 1])
---> 26 net(torch.rand(10, 2))

~/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py in __call__(self, *input, **kwargs)
    475             result = self._slow_forward(*input, **kwargs)
    476         else:
--> 477             result = self.forward(*input, **kwargs)
    478         for hook in self._forward_hooks.values():
    479             hook_result = hook(self, input, result)

~/anaconda3/lib/python3.6/site-packages/torch/nn/parallel/data_parallel.py in forward(self, *inputs, **kwargs)
    120         if len(self.device_ids) == 1:
    121             return self.module(*inputs[0], **kwargs[0])
--> 122         replicas = self.replicate(self.module, self.device_ids[:len(inputs)])
    123         outputs = self.parallel_apply(replicas, inputs, kwargs)
    124         return self.gather(outputs, self.output_device)

~/anaconda3/lib/python3.6/site-packages/torch/nn/parallel/data_parallel.py in replicate(self, module, device_ids)
    125 
    126     def replicate(self, module, device_ids):
--> 127         return replicate(module, device_ids)
    128 
    129     def scatter(self, inputs, kwargs, device_ids):

~/anaconda3/lib/python3.6/site-packages/torch/nn/parallel/replicate.py in replicate(network, devices, detach)
     50                     replica._parameters[key] = None
     51             else:
---> 52                 param_idx = param_indices[param]
     53                 for j in range(num_replicas):
     54                     replica = module_copies[j][i]

KeyError: Parameter containing:
tensor([[-0.4050,  0.0905],
        [-0.1446, -0.5699]], device='cuda:0')