hughperkins / pytorch

Python wrappers for torch and lua
BSD 2-Clause "Simplified" License
431 stars 70 forks source link

pop type torch.CudaTensor not implemented #35

Closed rracinskij closed 7 years ago

rracinskij commented 7 years ago

Hi, I get a strange error while trying a forward pass through a loaded Torch model:

function TorchModel:forward(input)
  local output = self.net:forward(torch.rand(1,3,112,112):cuda())
  return output
end
PyTorchAug.py", line 181, in popSomething
    raise Exception('pop type ' + str(typestring) + ' not implemented')
Exception: pop type torch.CudaTensor not implemented
hughperkins commented 7 years ago

It means you're returning a cudatensor from the lua side, into the python side.

Your easiest option would be to convert it to a FloatTensor on the lua side, before passing it into the python.

hughperkins commented 7 years ago

(so eg something like return output:float() )

rracinskij commented 7 years ago

Yes, it works. The error was referenced to local output = self.net:forward(torch.rand(1,3,112,112):cuda()) and not to the return output, so it was a bit confusing. Many thanks!

hughperkins commented 7 years ago

Cool :-)