-
Notifications
You must be signed in to change notification settings - Fork 174
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
Bad mix with apply in DataParallelTable ? #262
Comments
Can't reproduce here. The error looks as if you were passing that function to a thread, but you aren't using the threaded EDIT: it works for me even with threads enabled |
Ok , thanks for trying it out. I'll try this snippet on another machine to see if I manage to reproduce it. |
@apaszke are you using lua5.2? I can repro on several machines with luajit2.1 and freshly installed torch |
@szagoruyko It was LuaJIT. I reinstalled everything and I can confirm the issue now. |
I got it to work, but it's a bit of a hack 😜 require 'cunn'
model = nn.DataParallelTable(1)
model:add(nn.SpatialConvolution(3,96,7,7,3,3),1)
model:add(nn.SpatialConvolution(3,96,7,7,3,3),2)
model:cuda()
input = torch.randn(32,3,224,224):cuda()
function f(m)
m.updateOutput = function(self, i)
return torch.getmetatable(torch.type(m)).updateOutput(self, i)
end
end
model:apply(f)
print(model:forward(input):size()) I don't really know why it tries to serialise THNN along with the closure in your example. Also it seems to work with older Torch versions, which is even weirder. |
Still, this is a problem with serialization, not with DPT. Below is a snippet that reproduces it: require 'nn'
model = nn.Sequential()
model:add(nn.SpatialConvolution(3,96,7,7,3,3),1)
function f(m)
m._uO = m.updateOutput
m.updateOutput = function(self, i)
return m:_uO(i)
end
end
model:apply(f)
model:clone() |
It serializes THNN because the reference chain: m.updateOutput -> ff -> THNN.optionalTensor i.e.
On Thu, Apr 28, 2016 at 4:14 PM, Adam Paszke [email protected]
|
@colesbury But, if you don't do |
If so, this is probably a better workaround: require 'nn'
model = nn.Sequential()
model:add(nn.SpatialConvolution(3,96,7,7,3,3),1)
function f(m)
local mt = getmetatable(m)
mt._updateOutput = mt.updateOutput
m.updateOutput = function(self, i)
return self:_updateOutput(i)
end
end
model:apply(f)
model:clone() The only downside is that it will break if you save the model to a file and load it without |
There seems to be a problem (or at least a behaviour which is not compatible with other modules) with
apply
inDataParallelTable
.The following snippet reproduces the problem:
The error is the following:
Here is a related issue fmassa/optimize-net#12
Is it an abusive use of
apply
(and should not be supported) ?The text was updated successfully, but these errors were encountered: