自定义图层的nn.DataParallelTable失败

时间:2017-07-15 15:26:58

标签: lua torch

multi-gpu模型初始化代码:

local dpt = nn.DataParallelTable(1, true, true)
         :add(model, gpus)
         :threads(function()
            local cudnn = require 'cudnn'
            cudnn.fastest, cudnn.benchmark = fastest, benchmark
         end)
dpt.gradInput = nil

model = dpt:cuda()

处理model:parameters()model:getParameters()时出错:

FATAL THREAD PANIC: (read) /home/daniel/torch/install/share/lua/5.2/torch/File.lua:343: unknown Torch class <nn.Reorg>
FATAL THREAD PANIC: (read) /home/daniel/torch/install/share/lua/5.2/torch/File.lua:343: unknown Torch class <nn.Reorg>

<nn.Reorg>是我在models/Reorg.lua中定义的自定义图层,它只对图层输入执行简单的复制操作。
它在CPU和单GPU情况下工作正常。

1 个答案:

答案 0 :(得分:0)

我终于明白了,只需添加一行代码:

:threads(function()
            require 'models/Reorg'
            local cudnn = require 'cudnn'
            cudnn.fastest, cudnn.benchmark = fastest, benchmark
         end)

线程没有加载文件(为什么???),我必须手动加载...