Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RuntimeError: 'lengths' argument should be a 1D CPU int64 tensor, but got 1D cuda:0 Long tensor #37

Closed
Jeriousman opened this issue Mar 17, 2022 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@Jeriousman
Copy link

Jeriousman commented Mar 17, 2022

Describe the bug
When I run DIEN model, I get this error. I tried lengths.cpu(), lengths.to('cpu') but none of them work. Would you provide a solution for this?

DIEN_augru
HBox(children=(FloatProgress(value=0.0, description='training routine', max=2.0, style=ProgressStyle(descripti…
HBox(children=(FloatProgress(value=0.0, description='train', max=8486.0, style=ProgressStyle(description_width…
HBox(children=(FloatProgress(value=0.0, description='valid', max=947.0, style=ProgressStyle(description_width=…
GPU is available, transfer model to GPU.
Traceback (most recent call last):

  File "<ipython-input-47-cf075d4611bd>", line 18, in <module>
    scores1, model_loss_curves1 = run(models)

  File "<ipython-input-47-cf075d4611bd>", line 9, in run
    train_loader, valid_loader, notebook=True, auxiliary_loss_rate=1)

  File "/home/hojun/anaconda3/envs/ai/lib/python3.6/site-packages/prediction_flow/pytorch/functions.py", line 57, in fit
    pred = model(batch)

  File "/home/hojun/anaconda3/envs/ai/lib/python3.6/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)

  File "/home/hojun/anaconda3/envs/ai/lib/python3.6/site-packages/prediction_flow/pytorch/dien.py", line 100, in forward
    query, pos_hist, keys_length, neg_hist))

  File "/home/hojun/anaconda3/envs/ai/lib/python3.6/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)

  File "/home/hojun/anaconda3/envs/ai/lib/python3.6/site-packages/prediction_flow/pytorch/nn/interest.py", line 235, in forward
    enforce_sorted=False)

  File "/home/hojun/anaconda3/envs/ai/lib/python3.6/site-packages/torch/nn/utils/rnn.py", line 244, in pack_padded_sequence
    _VF._pack_padded_sequence(input, lengths, batch_first)

RuntimeError: 'lengths' argument should be a 1D CPU int64 tensor, but got 1D cuda:0 Long tensor

Additional context
Pytorch 1.7.1v

@Jeriousman Jeriousman added the bug Something isn't working label Mar 17, 2022
@GitHub-HongweiZhang
Copy link
Owner

sorry for that. The lib doesn't support torch 1.7.x

@GitHub-HongweiZhang
Copy link
Owner

the same issue as
#35

@Jeriousman
Copy link
Author

Thank you for your prompt reply. Okay then pytorch version should be the problem. Thank you!

@Jeriousman
Copy link
Author

Well, I upgraded to 1.8.1-cu101 pytorch, but it is still not working. Can you tell me which version should I have to make it work?

@GitHub-HongweiZhang
Copy link
Owner

I think it should work at 1.4.x. sorry, I am too busy recently. I don't have time to update it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants