Skip to content

Commit

Permalink
Fix an issue occurring in the cuGraph-DGL example for "mixed" mode. (#…
Browse files Browse the repository at this point in the history
…3927)

Fixing the following bug:
```
Training in mixed mode.
Loading data
Traceback (most recent call last):
  File "/opt/rapids/cugraph/python/cugraph-dgl/examples/graphsage/node-classification.py", line 249, in <module>
    g.get_node_storage(key="feat", ntype="_N")
  File "/usr/local/lib/python3.10/dist-packages/dgl/frame.py", line 530, in fetch
    return super().fetch(indices, device, pin_memory=pin_memory, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/dgl/storages/pytorch_tensor.py", line 40, in fetch
    raise ValueError(
ValueError: Got indices on device cuda:0 whereas the feature tensor is on cpu. Please either (1) move the graph to GPU with to() method, or (2) pin the graph with pin_memory_() method.
```
which appears in `mixed` mode.

NOTE: the option `(1) move the graph to GPU with to()` is not available because in mixed mode the graph must be on the CPU.

Authors:
  - Andrei Ivanov (https://github.com/drivanov)
  - Brad Rees (https://github.com/BradReesWork)

Approvers:
  - Alex Barghi (https://github.com/alexbarghi-nv)
  - Vibhu Jawa (https://github.com/VibhuJawa)

URL: #3927
  • Loading branch information
drivanov authored Oct 30, 2023
1 parent a57f779 commit e0c3a93
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion python/cugraph-dgl/examples/graphsage/node-classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,9 @@ def train(args, device, g, dataset, model):

else:
g = g.to("cuda" if args.mode == "gpu_dgl" else "cpu")
device = torch.device("cpu" if args.mode == "cpu" else "cuda")
device = torch.device(
"cpu" if args.mode == "cpu" or args.mode == "mixed" else "cuda"
)

# create GraphSAGE model
feat_shape = (
Expand Down

0 comments on commit e0c3a93

Please sign in to comment.