You can run
model_on_cpu = model_on_gpu:float()
to make a copy of the object from GPU to CPU
--
You received this message because you are subscribed to the Google Groups "torch7" group.
To unsubscribe from this group and stop receiving emails from it, send an email to torch7+un...@googlegroups.com.
To post to this group, send email to tor...@googlegroups.com.
Visit this group at http://groups.google.com/group/torch7.
For more options, visit https://groups.google.com/d/optout.
function replaceModules(net, orig_class_name, replacer) local nodes, container_nodes = net:findModules(orig_class_name) for i = 1, #nodes do for j = 1, #(container_nodes[i].modules) do if container_nodes[i].modules[j] == nodes[i] then local orig_mod = container_nodes[i].modules[j] container_nodes[i].modules[j] = replacer(orig_mod) end end endend
function cudnnNetToCpu(net) local net_cpu = net:clone():float()
replaceModules(net_cpu, 'cudnn.SpatialConvolution', function(orig_mod) local cpu_mod = nn.SpatialConvolutionMM(orig_mod.nInputPlane, orig_mod.nOutputPlane, orig_mod.kW, orig_mod.kH, orig_mod.dW, orig_mod.dH, orig_mod.padW, orig_mod.padH) cpu_mod.weight:copy(orig_mod.weight) cpu_mod.bias:copy(orig_mod.bias) return cpu_mod end)
replaceModules(net_cpu, 'cudnn.ReLU', function() return nn.ReLU() end)
return net_cpuend
torch.save('cpu_net.bin', cudnnNetToCpu(gpu_net))attempt to call method 'double' (a nil value)
orattempt to call method 'float' (a nil value)
model = torch.load(modelName)
model = model.float() # model = model.double()