This arises because the two tensors you want to cat are not on the same device, shift them either to the CPU or the GPU.



 Anna_yah:

outputs = torch.cat((outputs,v.detach()),dim=0)


Also here you are concatenating an empty tensor to your model output, I do not know what exactly is the overall model and objective, but this statement seems to have no effect.



 Anna_yah:

outputs = torch.tensor(outputs,  requires_grad=True) 


Here you do not need to create the tensor all over again, you could just do outputs.require_grad=True