KEQA_WSDM19 icon indicating copy to clipboard operation
KEQA_WSDM19 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 dodoyeon opened this issue 4 years ago • 6 comments

20200524_162658

I had error in this lines of code. The error is TypeError: can’t convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.

20200524_162720

Can you help me? Thank you

dodoyeon avatar May 24 '20 07:05 dodoyeon

I met this problem too, when training predicates ..

therealhieu avatar Sep 08 '20 13:09 therealhieu

You should make sure that, you either run on GPU and put all the data on GPU, or run on CPU and put all the data on CPU.

xhuang31 avatar Nov 17 '20 09:11 xhuang31

Hi @xhuang31 ,

I met the issue too, but I don't understand what you mean. "run on GPU and put all the data on GPU"<-- What does the "data" in sentence mean? I just run "python3.6 train_pred.py --qa_mode GRU --fix_embed --gpu 0" in my docker environment. Is there any config I should set?

Thx

===Updated===

I sovle this issue by modifying the line 214 of train_pred.py. learned_pred = euclidean_distances(answer.cpu().data.numpy(), predicates_emb.cpu().numpy()).argmin(axis=1)

Then, It can work now. Thx again.

forrestliao avatar Nov 24 '20 01:11 forrestliao

I met this problem too, when training predicates ..

Hello, I'm also studying this paper recently. Can I have some questions to communicate with you? If it's convenient

azhe1234 avatar Oct 21 '21 07:10 azhe1234

I met this problem too, when training predicates ..

Hello, I'm also studying this paper recently. Can I have some questions to communicate with you? If it's convenient

Hi, I am not working on this topic anymore. I also failed to use the code in this repo for experiments.

therealhieu avatar Oct 21 '21 08:10 therealhieu

ok,thank you ------------------ 原始邮件 ------------------ 发件人: "xhuang31/KEQA_WSDM19" @.>; 发送时间: 2021年10月21日(星期四) 下午4:17 @.>; 抄送: "硬币 @.@.>; 主题: Re: [xhuang31/KEQA_WSDM19] TypeError: can’t convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first (#14)

I met this problem too, when training predicates ..

Hello, I'm also studying this paper recently. Can I have some questions to communicate with you? If it's convenient

Hi, I am not working on this topic anymore. I also failed to use the code in this repo for experiments.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

azhe1234 avatar Oct 21 '21 08:10 azhe1234