Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block if using pytorch-summary #171

Open
navi2000 opened this issue May 15, 2021 · 0 comments
Open

Block if using pytorch-summary #171

navi2000 opened this issue May 15, 2021 · 0 comments

Comments

@navi2000
Copy link

I have been having some blocking issues. I isolated the problem in this 30 lines code:

import numpy as np
import torch
from torchsummary import summary
import torch.multiprocessing as mp
from torch.nn import functional as F

class MyModel(torch.nn.Module):
    def __init__(self):
        super(MyModel, self).__init__()
        self.l1 = torch.nn.Linear(64, 100)
        self.last = torch.nn.Linear(100, 4)
    def forward(self,x):
        y = F.relu(self.l1(x))
        result = F.log_softmax(self.last(y),dim=0)
        return result


def worker(t, worker_model):
    state = torch.from_numpy(np.random.rand(1, 64)).float()
    value = worker_model(state)
    print ("Never arrive here")


model = MyModel()
model.share_memory()
#summary(model, (1,64))

p = mp.Process(target=worker, args=(0, model))
p.start() 
p.join()

If you uncomment the 'summary' line, the worker function will be blocked in the call to worker_model(state).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant