hgraph2graph icon indicating copy to clipboard operation
hgraph2graph copied to clipboard

TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first

Open amir-tagh opened this issue 2 years ago • 2 comments

Hello,

I am using the finetune_generator.py and I am getting the following error. does anybody know how to solve this.

Thanks,

Loading from checkpoint ckpt/inforna-pretrained/model.ckpt.5000 After pruning 257 -> 257 Epoch 0 training... 0%| | 0/13 [00:25<?, ?it/s] Traceback (most recent call last): File "/apps/hgraph2graph/20210428/hgraph2graph/finetune_generator.py", line 152, in meters = meters + np.array([kl_div, loss.item(), wacc * 100, iacc * 100, tacc * 100, sacc * 100]) File "/apps/hgraph2graph/20210428/lib/python3.7/site-packages/torch/_tensor.py", line 732, in array return self.numpy() TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.

amir-tagh avatar Jun 22 '22 20:06 amir-tagh

In train_generator.py, change line 96 to:

meters = meters + np.array([kl_div, loss.item(), wacc.cpu() * 100, iacc.cpu() * 100, tacc.cpu() * 100, sacc.cpu() * 100])

dbhaskar92 avatar Jul 11 '22 01:07 dbhaskar92

Thanks.

amir-tagh avatar Jul 11 '22 12:07 amir-tagh