# Freezing layers issue for parallel GPU

**URL:** <https://discuss.pytorch.org/t/freezing-layers-issue-for-parallel-gpu/73658>\
**Category:** vision\
**Created:** [March 18, 2020, 4:17pm UTC](https://discuss.pytorch.org/t/freezing-layers-issue-for-parallel-gpu/73658 "2020-03-18T16:17:46Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Han\_Brian\_Lee](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/han_brian_lee/32/14578_2.png) [@Han\_Brian\_Lee](https://discuss.pytorch.org/u/Han_Brian_Lee)\
**Post date:** [March 23, 2020, 5:02pm UTC](https://discuss.pytorch.org/t/freezing-layers-issue-for-parallel-gpu/73658/3 "2020-03-23T17:02:53Z")

</div>

Here it is. If you comment out the model = nn.DataParallel(model) line, no error occurs, otherwise the error occurs (on a computer with multiple GPUs):

```auto
from __future__ import print_function
from __future__ import division
import torch
import torch.nn as nn
import torch.optim as optim
import numpy as np

class mynet(torch.nn.Module):
    def __init__ (self):
        super(mynet, self). __init__ ()
        self.fc = nn.Linear(2, 1, bias=False)

    def forward(self, x):        
        for param in self.fc.parameters():
            param.requires_grad = False

        return self.fc(x)

model = mynet()
model = nn.DataParallel(model) # comment out this line to make the error go away
model.cuda()

data = np.array([0.0, 1.0])
x = torch.from_numpy(data).float().unsqueeze(0).unsqueeze(0).unsqueeze(0)
gt = torch.from_numpy(np.array([0.0])).float().unsqueeze(0).unsqueeze(0).unsqueeze(0)

# model.train()
result = model(x=x.cuda())

```

---

_[View the full topic](https://discuss.pytorch.org/t/freezing-layers-issue-for-parallel-gpu/73658)._
