# Problem consisting of Pyinstaller and Pytorch

**URL:** <https://discuss.pytorch.org/t/problem-consisting-of-pyinstaller-and-pytorch/130049>\
**Category:** reinforcement-learning\
**Created:** [August 23, 2021, 1:35pm UTC](https://discuss.pytorch.org/t/problem-consisting-of-pyinstaller-and-pytorch/130049 "2021-08-23T13:35:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![DavidLin](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/davidlin/32/41539_2.png) [@DavidLin](https://discuss.pytorch.org/u/DavidLin)\
**Post date:** [August 23, 2021, 1:35pm UTC](https://discuss.pytorch.org/t/problem-consisting-of-pyinstaller-and-pytorch/130049/1 "2021-08-23T13:35:32Z")

</div>

Hi guys, I recently ran into a problem. My project requires me to use pyinstaller to package the code file using the pytorch library into an exe file, but when the package is successful, an error “Key already registered with the same priority C10” is generated.

I am puzzled, because I run normally under Anaconda5.2 environment (Python3.7)

So I wrote a very simple torch code, but the same situation still occurs (the operation fails after packaging(Pyinstaller), and the error “Key already registered with the same priority C10” is reported)  
Here is my simple code:

```auto
import torch
import torch.nn as nn
from torch.autograd import Variable
import matplotlib.pyplot as plt
import torch.nn.functional as F

x = torch.unsqueeze(torch.linspace(-1, 1, 100), dim=1)
y = x.pow(2) + torch.randn(x.size()) * 0.1
x, y = Variable(x), Variable(y)

# plt.scatter(x.data.numpy(), y.data.numpy())
# plt.show()

class Net(nn.Module):
    def __init__ (self):
        super(Net, self). __init__ ()
        self.fc1 = nn.Linear(1, 8)
        self.fc2 = nn.Linear(8, 4)
        self.fc3 = nn.Linear(4, 1)
        self.opti = torch.optim.Adam(self.parameters(), lr=0.01)
        self.loss_fun = torch.nn.MSELoss()
        
        self.loss_append = []

    def forward(self, x):
        x = self.fc1(x)
        x = F.relu(x)
        x = self.fc2(x)
        x = F.relu(x)
        x = self.fc3(x)
        return x

    def learn(self, x, y):
        out = self.forward(x)
        loss = self.loss_fun(out, y)
        print('当前误差:', loss.data.item())
        self.loss_append.append(loss.data.item())
        self.opti.zero_grad()
        loss.backward()
        self.opti.step()
def main():
    update_net = Net() 
    soft_net = Net()
    for i in range(500):
        update_net.learn(x, y)
        for w_b in soft_net.state_dict().keys():
            eval('soft_net.' + w_b + '.data.mul_(1 - 0.01)')
            eval('soft_net.' + w_b + '.data.add_(0.01 * (update_net.' + w_b + '.data))')

    print("successful")
# plt.plot(x.data.numpy(), update_net.forward(x).data.numpy(), color='red')
# plt.plot(x.data.numpy(), soft_net.forward(x).data.numpy(), color='blue')
# plt.scatter(x.data.numpy(), y.data.numpy(), color='black')
# plt.show()
if __name__ == ' __main__':
    main()

```

Can u be my superhero???  
Plus:My computer configuration  
Operation System: Windows Server 2008 R2  
CPU：Core i7-10870H@2.20GHz  
GPU: NVIDIA RTX 3060  
ERROR：

 ![微信图片_20210823201001](https://discuss.pytorch.org/uploads/default/original/3X/9/b/9b480b11be8b3c6a17ac48968978da431abec6c2.png)

---

<div class="post-metadata">

**Author:** ![gasgallo](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/gasgallo/32/61214_2.png) [@gasgallo](https://discuss.pytorch.org/u/gasgallo)\
**Post date:** [June 12, 2023, 1:56pm UTC](https://discuss.pytorch.org/t/problem-consisting-of-pyinstaller-and-pytorch/130049/2 "2023-06-12T13:56:55Z")

</div>

Hi,

did you or anybody else ever solved this issue?
