简体   繁体   中英

cannot run torch code on gpu

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.

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.

传递给ClassNLLCriterion的目标(正向第二个参数)需要是CudaTensor。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM