Hello Lukas!



 Lukas_Lansche:

I first tried it with :
y = merged_mask.int().cuda()

but then I got this error:
RuntimeError: Expected object of scalar type Long but got scalar type Int for argument #2 'target' in call to _thnn_nll_loss2d_forward



This makes sense.  CrossEntropyLoss requires long for its
target.


So i changed .int() into .long() and this following error appears:
RuntimeError: cuDNN error: CUDNN_STATUS_NOT_INITIALIZED



This looks like you’re having a cuda / gpu error.
First try running your code entirely on your cpu.  (Get rid of any
.cuda() calls so that all of your tensors – model, input, target,
etc. – are on the cpu.)  See if you can get this to work.
Then try something simple on the gpu.  Create two FloatTensors,
move them to the gpu, and then try to add them together, or the
like.
If this works, but your real code keeps giving cuDNN error, then
there will be more debugging to do.


now there could be one issue I’m thinking of, my class labels aren’t 0 to 4, they are 1 to 5 does this make any difference ?


Yes, this will also be a problem (but it doesn’t explain the cuda
error).  The target for CrossEntropyLoss must be (long) integer
class labels that run from 0 to nClass - 1.  If they include a
value of nClass (or larger), you will get an error – “index out
of range”, or something similar, I think.
Good luck.
K. Frank