Sample code runs on 3.7 but not 3.6

I am new to Pytorch. I have been running the sample code for reinforcment learning ( on a different data set that has 5 output classes. It runs fine on my Python 3.7 environment, but gives a runtime error when running on Python 3.6

THCudaCheck FAIL file=C:/cb/pytorch_1000000000000/work/aten/src\THC/generic/ line=29 error=710 : device-side assert triggered
C:/cb/pytorch_1000000000000/work/aten/src/THCUNN/ block: [0,0,0], thread: [0,0,0] Assertion t >= 0 && t < n_classes failed.

I’ve been comparing my environment for days and can’t see any tangible differences. Any pointers in the right directions would be appreciated.

This error is raised, if you pass invalid target indices to nn.CrossEntropyLoss or nn.NLLLoss, which both expect the target tensor to contain values in the range [0, nb_classes-1].
I don’t think the Python version changes this error, so you would have to check the target values instead.

Thanks for the quick response. I’ll look at it, but it is the exact same code from the PyTorch website. All I am changing is the environment in PyCharm and re-running the same code. I’ll let you know my resolution.

I downloaded the Notebook with the sample data and it ran fine in 3.6. When I pointed the Notebook at my data, it failed again. I found where the number of output classes was hardcoded, changed it to the correct number of classes and it ran fine. So problem resolved, but I still don’t know why the wrong number of classes ran on 3.7. Not going to worry about it, thank you for your help.