1
votes

I tried to run the code in torch tutorial, but when i wanna run it on gpu using :cuda(), I keep receiving the following error

/opt/zbstudio/bin/linux/x64/lua: /home/andybug/torch/install/share/lua/5.1/nn/THNN.lua:110: bad argument #3 to 'v' (cannot convert 'struct THCudaTensor *' to 'struct THCudaLongTensor *') stack traceback: [C]: in function 'v' /home/andybug/torch/install/share/lua/5.1/nn/THNN.lua:110: in function 'ClassNLLCriterion_updateOutput' ...bug/torch/install/share/lua/5.1/nn/ClassNLLCriterion.lua:41: in function 'forward' ...ug/torch/install/share/lua/5.1/nn/StochasticGradient.lua:35: in function 'train' /home/andybug/Documents/NLP/lua torch/torch-prac/main.lua:74: in main chunk [C]: at 0x00404f08

googled this problem but no valid answers, tried reinstall nn, cunn, .etc, which didn't work.

2

2 Answers

0
votes

I've experienced the same problem while loading Coco data as Cuda tensors. As loading Pascal2012 data was fine, I thought I had an issue with data loaders or the iterator (I am using torchnet's parallel dataset iterator). On reinstalling cutorch I found something is wrong. Then reinstalled Cuda (8 in my case) as it was colliding with other versions (7.5) and finally installed torch from scratch. Now everything works like a charm.

-1
votes

The target you pass to ClassNLLCriterion (2nd argument in forward) needs to be a CudaTensor.