How to convert a list of cuda tensors to a list of cpu tensors?

So I have a big list of cuda tensors containing loss values of each iteration but I can’t even scatter plot it. How can I convert it to a list of cpu tensors or even numpy array without iterating over the indices? Thank You!


In this post I have written a code to transfer a list of CPU tensors to GPU which all have the same shape (in your case all have shape of (1, )).


1 Like

Thank you so much @Nikronic .

Just creating a new tensor with torch.tensor() worked. Then simply plotted the scatter plot on torch tensor (with device = cpu).

new_tensor = torch.tensor(list_of_cuda_tensors, device = 'cpu')

1 Like

But, what if you want to keep it as a list of tensors after the transfer from gpu to cpu

1 Like