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: Expected object of device type cuda but got device type cpu for argument #2 'mat2' in call to _th_mm #4

Open
debinz opened this issue Dec 17, 2019 · 3 comments
Labels
bug Something isn't working

Comments

@debinz
Copy link

debinz commented Dec 17, 2019

Hi

I am using your great code! I have slightly modified your models.py to fit my regression task, but when I run the train.py, error occurred:

Traceback (most recent call last):
File "train.py", line 1273, in
main()
File "train.py", line 1250, in main
benchmark_task(prog_args, writer=writer)
File "train.py", line 1024, in benchmark_task
writer=writer,
File "train.py", line 190, in train
ypred, att_adj = model(h0, adj, batch_num_nodes, assign_x=assign_input) #use the 'forward' that is in model class
File "/home/omnisky/venv/lib/python3.7/site-packages/torch/nn/modules/module.py", line 541, in call
result = self.forward(*input, **kwargs)
File "/home/omnisky/Documents/individual_variance/gnn-model-explainer/models.py", line 570, in forward
self.assign_pred_modulesi
File "/home/omnisky/venv/lib/python3.7/site-packages/torch/nn/modules/module.py", line 541, in call
result = self.forward(*input, **kwargs)
File "/home/omnisky/venv/lib/python3.7/site-packages/torch/nn/modules/linear.py", line 87, in forward
return F.linear(input, self.weight, self.bias)
File "/home/omnisky/venv/lib/python3.7/site-packages/torch/nn/functional.py", line 1372, in linear
output = input.matmul(weight.t())
RuntimeError: Expected object of device type cuda but got device type cpu for argument #2 'mat2' in call to _th_mm

Can you give some advice about that? Thank you for your kind assistance!

Zeng

@debinz debinz added the bug Something isn't working label Dec 17, 2019
@iamzhangyunlu
Copy link

Hi, have you already solved the problem?

@RexYing
Copy link
Owner

RexYing commented Jan 9, 2020

Thanks for pointing out.
Since the line number doesn't correspond, wonder if you the argument method is set to "base"?
The default should be base.

I'll refactor out some unused code so that it doesn't accidentally call an unused model.

@jiank2
Copy link

jiank2 commented Apr 24, 2020

I have the same problem. Probably, the reason is that prog_args.gpu is set to False, not sure why it is False since const is True and action is 'store_const' (at least this is what happened on my PC). My solution is kind of like brute force by comment out all if-condition that involves prog_args.gpu/self.gpu, which enforces the program to send all data into GPU.

I wonder if the authors could provide some hint on how to fix the weird prog_args.gpu value assignment.

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

4 participants