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

[GraphBolt][CUDA] Modify multiGPU example to use GPU sampling. #6961

Merged
merged 4 commits into from
Jan 18, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 16 additions & 17 deletions examples/multigpu/graphbolt/node_classification.py
mfbalin marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,6 @@ def create_dataloader(
shuffle=shuffle,
drop_uneven_inputs=drop_uneven_inputs,
)
datapipe = datapipe.sample_neighbor(graph, args.fanout)
datapipe = datapipe.fetch_feature(features, node_feature_keys=["feat"])

############################################################################
# [Note]:
# datapipe.copy_to() / gb.CopyTo()
Expand All @@ -137,8 +134,11 @@ def create_dataloader(
# [Output]:
# A CopyTo object copying data in the datapipe to a specified device.\
############################################################################
datapipe = datapipe.copy_to(device)
dataloader = gb.DataLoader(datapipe, num_workers=args.num_workers)
datapipe = datapipe.copy_to(device, extra_attrs=["seed_nodes"])
datapipe = datapipe.sample_neighbor(graph, args.fanout)
datapipe = datapipe.fetch_feature(features, node_feature_keys=["feat"])

dataloader = gb.DataLoader(datapipe)

# Return the fully-initialized DataLoader object.
return dataloader
Expand Down Expand Up @@ -272,15 +272,17 @@ def run(rank, world_size, args, devices, dataset):
rank=rank,
)

graph = dataset.graph
features = dataset.feature
# Pin the graph and features to enable GPU access.
dataset.graph.pin_memory_()
dataset.feature.pin_memory_()

train_set = dataset.tasks[0].train_set
valid_set = dataset.tasks[0].validation_set
test_set = dataset.tasks[0].test_set
args.fanout = list(map(int, args.fanout.split(",")))
num_classes = dataset.tasks[0].metadata["num_classes"]

in_size = features.size("node", None, "feat")[0]
in_size = dataset.feature.size("node", None, "feat")[0]
hidden_size = 256
out_size = num_classes

Expand All @@ -291,8 +293,8 @@ def run(rank, world_size, args, devices, dataset):
# Create data loaders.
train_dataloader = create_dataloader(
args,
graph,
features,
dataset.graph,
dataset.feature,
train_set,
device,
drop_last=False,
Expand All @@ -301,8 +303,8 @@ def run(rank, world_size, args, devices, dataset):
)
valid_dataloader = create_dataloader(
args,
graph,
features,
dataset.graph,
dataset.feature,
valid_set,
device,
drop_last=False,
Expand All @@ -311,8 +313,8 @@ def run(rank, world_size, args, devices, dataset):
)
test_dataloader = create_dataloader(
args,
graph,
features,
dataset.graph,
dataset.feature,
test_set,
device,
drop_last=False,
Expand Down Expand Up @@ -384,9 +386,6 @@ def parse_args():
help="Fan-out of neighbor sampling. It is IMPORTANT to keep len(fanout)"
" identical with the number of layers in your model. Default: 15,10,5",
)
parser.add_argument(
"--num-workers", type=int, default=0, help="The number of processes."
)
return parser.parse_args()


Expand Down