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

Cannot assign node feature "h" on device cuda:0 to a graph on device cpu. #12

Closed
Qidong-Liu opened this issue Nov 9, 2020 · 3 comments

Comments

@Qidong-Liu
Copy link

R-GCN Model
dataset="PubMed"
python 3.7 pytorch 1.7.0 dgl-cu102 0.5.2

Traceback (most recent call last):
File "src/main.py", line 185, in
main(args)
File "src/main.py", line 90, in main
embed, pred = model(g, node_id, edge_type, edge_norm)
File "/home/lqd/software/anaconda3/envs/HNE/lib/python3.7/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "/home/lqd/code/HNE-master/Model/R-GCN/src/model.py", line 117, in forward
output = self.rgcn.forward(g, h, r, norm)
File "/home/lqd/code/HNE-master/Model/R-GCN/src/model.py", line 52, in forward
h = layer(g, h, r, norm)
File "/home/lqd/software/anaconda3/envs/HNE/lib/python3.7/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "/home/lqd/software/anaconda3/envs/HNE/lib/python3.7/site-packages/dgl/nn/pytorch/conv/relgraphconv.py", line 274, in forward
g.srcdata['h'] = feat
File "/home/lqd/software/anaconda3/envs/HNE/lib/python3.7/site-packages/dgl/view.py", line 81, in setitem
self._graph._set_n_repr(self._ntid, self._nodes, {key : val})
File "/home/lqd/software/anaconda3/envs/HNE/lib/python3.7/site-packages/dgl/heterograph.py", line 3811, in _set_n_repr
' same device.'.format(key, F.context(val), self.device))
dgl._ffi.base.DGLError: Cannot assign node feature "h" on device cuda:0 to a graph on device cpu. Call DGLGraph.to() to copy the graph to the same device.

@xiaoyuxin1002
Copy link
Collaborator

It is a bug caused by the new version of DGL library.
I've updated the R-GCN codes accordingly for dgl-cu101 0.5.2.
Please feel free to check again.

@richa-choudhary
Copy link

The issue still persists!
Please do your work

@xiaoyuxin1002
Copy link
Collaborator

The issue still persists! Please do your work

I am pretty sure that the codes work with dgl-cu101 0.5.2.
Have you checked your version of dgl? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants