其他分享
首页 > 其他分享> > 用gpu跑代码时出现的问题

用gpu跑代码时出现的问题

作者:互联网

1、当代码都调试后,使用gpu跑,出现:
can't convert cuda:0 device type tensor to numpy.Use Tensor.cpu to copy the tensor to host memory first
此时根据提示,找到代码处的loss.detach().将其该成loss.detach().cpu().numpy()即可,原因:gpu式的tensor不能直接转成numpy

待更新!!!

标签:loss,tensor,代码,问题,gpu,detach,numpy,cpu
来源: https://www.cnblogs.com/zizz/p/16244833.html