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

2023-03-07,,

predict=predict.data.numpy() 这一行报错
意思是:如果想把CUDA tensor格式的数据改成numpy时
,需要先将其转换成cpu float-tensor随后再转到numpy格式。
numpy不能读取CUDA tensor 需要将它转化为 CPU tensor
将predict.data.numpy() 改为predict.data.cpu().numpy()即可

转 https://blog.csdn.net/qq_38410428/article/details/82973711

can't convert CUDA tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.的相关教程结束。

《can't convert CUDA tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first..doc》

下载本文的Word格式文档,以方便收藏与打印。