Thanks, using contiguous() helped solving the error. I should check what is actually doing because I have the feeling that it is going to slow down the training. If every time I index the Tensor it reallocates memory in order to make it contiguous there is something wrong going on.