Based on the error message it seems that the target might be uninitialized. Which PyTorch version are you using and if it’s an older one, could you update it to the latest release (1.9.0) or the nightly binary?