From e0c3a9391851528407bc085eeab202e6c260c9f4 Mon Sep 17 00:00:00 2001 From: Andrei Ivanov <32910461+drivanov@users.noreply.github.com> Date: Mon, 30 Oct 2023 06:10:52 -0700 Subject: [PATCH] Fix an issue occurring in the cuGraph-DGL example for "mixed" mode. (#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 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: https://github.com/rapidsai/cugraph/pull/3927 --- python/cugraph-dgl/examples/graphsage/node-classification.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python/cugraph-dgl/examples/graphsage/node-classification.py b/python/cugraph-dgl/examples/graphsage/node-classification.py index 320890b0312..539fd86d136 100644 --- a/python/cugraph-dgl/examples/graphsage/node-classification.py +++ b/python/cugraph-dgl/examples/graphsage/node-classification.py @@ -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 = (