-
Notifications
You must be signed in to change notification settings - Fork 55
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
Unwritable object <userdata> at <?>.callback.self.resnet.DataLoader.threads.__gc__ #82
Comments
This error message is saying that the Relevant snippet:
I think you have two options here: (1) create the |
I have a similar issue, however, I already required the relevant files that I think are necessary and I still get this error. Error: I think it's the threadPool object (= threads.Threads(...) ) in my trainManager object that somehow cannot be serialized. My code: I have a ThreadManager that initializes all the requires in the threads: function ThreadManager:__init(options)
self.threadPool = threads.Threads(
options.threadNumber,
function()
require 'torch'
local threads = require 'threads'
require 'image'
require 'dataManager'
require 'trainManager'
end,
function(threadId)
local seed = opt.manualSeed + threadId
torch.manualSeed(seed)
print("Start of new worker thread with id: " .. threadId)
end)
end I then pass the threadPool value to the TrainManager: function TrainManager:__init(model, options, criterion, optimisationState, dataManager, threadPool)
self.model = model
self.options = options
self.criterion = criterion
self.optimisationState = optimisationState
self.dataManager = dataManager
self.threadPool = threadPool
-- get model parameters
local modelParameters, gradientParameters = model:getParameters()
self.modelParameters = modelParameters
self.gradientParameters = gradientParameters
-- allocate gpu tensors
self.batchInputs = torch.CudaTensor()
self.batchLabels = torch.CudaTensor()
end And here I add jobs to the worker thread where the code fails: function TrainManager:test()
local model = self.model
local options = self.options
local dataManager = self.dataManager
local threadPool = self.threadPool
cutorch.synchronize()
--set dropouts to evaluation mode
model:evaluate()
local totalLoss = 0
local setSize = dataManager:getValidationSize()
for i=1, math.ceil(setSize/options.batchSize) do
-- builds up the testing queue
local startIndex = (i - 1) * options.batchSize + 1
local endIndex = math.min(i * options.batchSize , setSize)
local batchNumber = i
threadPool:addjob(
function()
-- runs on worker thread
-- loads new test batch
collectgarbage() -- free unused memory before allocating new batch
local inputsCpu, labelsCpu =
dataManager:getValidationBatch(startIndex, endIndex)
return self, inputsCpu, labelsCpu, batchNumber, totalLoss
end,
-- called on main thread after worker function finished
function(self, inputsCpu, labelsCpu, batchNumber, totalLoss)
-- TEST
end
)
end
...
end |
+1 I am also seeing the same issue. It looks like the gc is not being serialized properly? Just to be clear: like marcel1991@ I am also correctly initializing all objects on thread startup. The problem seems to be that when an upvalue object's method is called within the thread lambda, for some reason the I've been trying to debug this for a few hours and I'm making no progress. |
Hi, I modified the code fb.resnet.torch/dataloader.lua in order to read data triplet by triplet. But I encountered with an confusing error:
Below is my code...
Below is the original code:
The text was updated successfully, but these errors were encountered: