promach:

TypeError: can’t convert CUDA tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.


The error is because numpy doesnot support cuda. So you have to make a cpu copy first.
V_tensor = torch.rand(9).cuda()
np_array = V_tensor.cpu().numpy()