Closed soumith closed 9 years ago
torch.random is still broken for me.
require 'cutorch'
torch.setdefaulttensortype('torch.CudaTensor')
print(torch.random())
throws
/opt/torch/torch/install/bin/luajit: temp.lua:3: torch.CudaTensor does not implement the torch.random() function
@c0d3rman as a general good practice, do not set the default tensor type as torch.CudaTensor, there are a few API calls that are still broken. We have it on our roadmap to make cutorch completely API compatible with torch, but it is not finished.
In this particular case, you are trying to generate a single random number, not a tensor of random numbers, i.e. torch.random(10,5) will work for example.
OK, thanks! I'm just adapting a library to use the GPU (specifically DeepQLearning). Figured it would make things a lot easier to just set the default tensor type. The torch.random() statement in their code is this:
return (torch.random! % Brain.net_outputs) + 1
For now I'll try to make all tensors CudaTensors manually.
oh wow, that's a great start. let me know if you get stuck somewhere.
when set default tensor type to CudaTensor, these two functions dont work