I am getting exactly the same error but on a slightly different trivial example when using torchvision (C++) directly. The error appears when I try to use a VGG16 network but it works normally for a ResNet. I have submitted the issue in the torchvision repo: https://github.com/pytorch/vision/issues/2245 18
Can anyone verify if it is related to this bug or it is on the torchvision side?