torchnet compatibility을 추가하기 위해 병렬 데이터 로더를 torch-dataframe에 추가하려고합니다. 나는 tnt.ParallelDatasetIterator 및 changed it 그래서를 사용했습니다 :torch.serialize를 두 번 사용하면 토치의 메모리가 부족합니다.
- 기본 일괄 배치가 직렬화와 변환됩니다
- 배치가 직렬화 스레드 외부에서로드 스레드에서 스레드
- 로 전송됩니다 배치 데이터를 텐서로 변환
- tnt.Engine 설정과 일치 시키려면 텐서가
input
및target
키가있는 테이블에 반환됩니다.
문제는 enque
가 오류로 불리는 두 번째 발생 .../torch_distro/install/bin/luajit: not enough memory
. 나는 현재 mnist과 함께 일하고 있으며, 적응 된 번호는 mnist-example입니다. enque
루프는 이제 (메모리 디버깅 출력을 포함)과 같습니다 : 나는 collectgarbage
을 뿌려 또한 필요하지 않은 물건을 제거하기 위해 노력했습니다
-- `samplePlaceholder` stands in for samples which have been
-- filtered out by the `filter` function
local samplePlaceholder = {}
-- The enque does the main loop
local idx = 1
local function enqueue()
while idx <= size and threads:acceptsjob() do
local batch, reset = self.dataset:get_batch(batch_size)
if (reset) then
idx = size + 1
else
idx = idx + 1
end
if (batch) then
local serialized_batch = torch.serialize(batch)
-- In the parallel section only the to_tensor is run in parallel
-- this should though be the computationally expensive operation
threads:addjob(
function(argList)
io.stderr:write("\n Start");
io.stderr:write("\n 1: " ..tostring(collectgarbage("count")))
local origIdx, serialized_batch, samplePlaceholder = unpack(argList)
io.stderr:write("\n 2: " ..tostring(collectgarbage("count")))
local batch = torch.deserialize(serialized_batch)
serialized_batch = nil
collectgarbage()
collectgarbage()
io.stderr:write("\n 3: " .. tostring(collectgarbage("count")))
batch = transform(batch)
io.stderr:write("\n 4: " .. tostring(collectgarbage("count")))
local sample = samplePlaceholder
if (filter(batch)) then
sample = {}
sample.input, sample.target = batch:to_tensor()
end
io.stderr:write("\n 5: " ..tostring(collectgarbage("count")))
collectgarbage()
collectgarbage()
io.stderr:write("\n 6: " ..tostring(collectgarbage("count")))
io.stderr:write("\n End \n");
return {
sample,
origIdx
}
end,
function(argList)
sample, sampleOrigIdx = unpack(argList)
end,
{idx, serialized_batch, samplePlaceholder}
)
end
end
end
. 메모리 출력이 아니라 정직 :
Start
1: 374840.87695312
2: 374840.94433594
3: 372023.79101562
4: 372023.85839844
5: 372075.41308594
6: 372023.73632812
End
enque
루프 기능은 사소한 비 순서화 기능 (메모리 오류 제 enque
에서 발생하고있다)이다
iterFunction = function()
while threads:hasjob() do
enqueue()
threads:dojob()
if threads:haserror() then
threads:synchronize()
end
enqueue()
if table.exact_length(sample) > 0 then
return sample
end
end
end