Skip to content

Commit

Permalink
[GraphBolt] Modify multigpu example arguments (#6990)
Browse files Browse the repository at this point in the history
  • Loading branch information
RamonZhou authored Jan 22, 2024
1 parent 99a02f0 commit d67dae1
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions examples/multigpu/graphbolt/node_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,11 @@ def create_dataloader(
# [Output]:
# A CopyTo object copying data in the datapipe to a specified device.\
############################################################################
if not args.cpu_sampling:
if args.storage_device != "cpu":
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"])
if args.cpu_sampling:
if args.storage_device == "cpu":
datapipe = datapipe.copy_to(device)

dataloader = gb.DataLoader(datapipe, args.num_workers)
Expand Down Expand Up @@ -276,7 +276,7 @@ def run(rank, world_size, args, devices, dataset):
)

# Pin the graph and features to enable GPU access.
if not args.cpu_sampling:
if args.storage_device == "pinned":
dataset.graph.pin_memory_()
dataset.feature.pin_memory_()

Expand Down Expand Up @@ -388,15 +388,17 @@ def parse_args():
type=str,
default="10,10,10",
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",
" identical with the number of layers in your model. Default: 10,10,10",
)
parser.add_argument(
"--num-workers", type=int, default=0, help="The number of processes."
)
parser.add_argument(
"--cpu-sampling",
action="store_true",
help="Disables GPU sampling and utilizes the CPU for dataloading.",
"--mode",
default="pinned-cuda",
choices=["cpu-cuda", "pinned-cuda"],
help="Dataset storage placement and Train device: 'cpu' for CPU and RAM,"
" 'pinned' for pinned memory in RAM, 'cuda' for GPU and GPU memory.",
)
return parser.parse_args()

Expand All @@ -406,6 +408,7 @@ def parse_args():
if not torch.cuda.is_available():
print(f"Multi-gpu training needs to be in gpu mode.")
exit(0)
args.storage_device, _ = args.mode.split("-")

devices = list(map(int, args.gpu.split(",")))
world_size = len(devices)
Expand Down

0 comments on commit d67dae1

Please sign in to comment.