Skip to content

Commit 7c0fd85

Browse files
authored
Fix breaking torch.device(0) incompatibility for torch 2.5 (#151)
1 parent 8f9e62e commit 7c0fd85

File tree

13 files changed

+17
-17
lines changed

13 files changed

+17
-17
lines changed

benchmarks/api/bench_dist_neighbor_loader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
drop_last=True,
124124
with_edge=with_edge,
125125
collect_features=collect_features,
126-
to_device=torch.device(0),
126+
to_device=torch.device('cuda:0'),
127127
worker_options=glt.distributed.MpDistSamplingWorkerOptions(
128128
num_workers=sampling_nprocs,
129129
worker_devices=[torch.device('cuda', i % device_count) for i in range(sampling_nprocs)],

benchmarks/api/bench_feature.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def test_glt_ogbnproducts(split_ratio):
3636
csr_topo = glt.data.Topology(dataset[0].edge_index)
3737

3838
g = glt.data.Graph(csr_topo, 'CUDA', device=0)
39-
device = torch.device(0)
39+
device = torch.device('cuda:0')
4040
sampler = glt.sampler.NeighborSampler(g, [15, 10, 5], device=device)
4141

4242
cpu_tensor, id2index = glt.data.sort_by_in_degree(

benchmarks/api/bench_sampler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def test_glt_ogbnproducts(mode='GPU'):
3939
shuffle=True)
4040
csr_topo = glt.data.Topology(dataset[0].edge_index)
4141
g = glt.data.Graph(csr_topo, graph_mode, device=0)
42-
device = torch.device(0)
42+
device = torch.device('cuda:0')
4343
sampler = glt.sampler.NeighborSampler(g, [15, 10, 5], device=device)
4444
total_time = 0
4545
sampled_edges = 0

docs/get_started/node_class.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ train_loader = glt.loader.NeighborLoader(glt_dataset,
8585
batch_size=1024,
8686
shuffle=True,
8787
drop_last=True,
88-
device=torch.device(0),
88+
device=torch.device('cuda:0'),
8989
as_pyg_v1=True)
9090
```
9191
> **Note**

docs/tutorial/dist.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ random_partitioner = glt.partition.RandomPartitioner(
116116
edge_feat=None,
117117
edge_assign_strategy='by_src', # assign graph edges by src node.
118118
chunk_size=10000, # chunk size for node assignment
119-
device=torch.device(0) # device used for partitioning
119+
device=torch.device('cuda:0') # device used for partitioning
120120
)
121121
random_partitioner.partition()
122122
```
@@ -170,7 +170,7 @@ freq_partitioner = glt.partition.FrequencyPartitioner(
170170
edge_assign_strategy='by_src', # assign graph edges by src node.
171171
chunk_size=10000, # chunk size for node assignment
172172
cache_ratio=0.2, # cache 20% hottest graph nodes
173-
device=torch.device(0) # device used for partitioning
173+
device=torch.device('cuda:0') # device used for partitioning
174174
)
175175
freq_partitioner.partition()
176176
```
@@ -507,7 +507,7 @@ train_loader = glt.distributed.DistNeighborLoader(
507507
# Set to true to collect node features for sampled subgraphs.
508508
collect_features=True,
509509
# All sampled results will be moved to this device.
510-
to_device=torch.device(0),
510+
to_device=torch.device('cuda:0'),
511511
# Use `MpDistSamplingWorkerOptions`.
512512
worker_options=mp_options
513513
)
@@ -589,7 +589,7 @@ train_loader = glt.distributed.DistNeighborLoader(
589589
input_nodes=train_idx,
590590
batch_size=1024,
591591
collect_features=True,
592-
to_device=torch.device(0),
592+
to_device=torch.device('cuda:0'),
593593
worker_options=collocated_options
594594
)
595595
```
@@ -645,7 +645,7 @@ train_loader = glt.distributed.DistNeighborLoader(
645645
input_nodes=train_idx,
646646
batch_size=1024,
647647
collect_features=True,
648-
to_device=torch.device(0),
648+
to_device=torch.device('cuda:0'),
649649
worker_options=remote_options
650650
)
651651
```

docs/tutorial/graph_ops.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class NeighborSampler(BaseSampler):
3838
def __init__(self,
3939
graph: Union[Graph, Dict[str, Graph]],
4040
num_neighbors: NumNeighbors,
41-
device: torch.device=torch.device('cuda', 0),
41+
device: torch.device=torch.device('cuda:0'),
4242
with_edge: bool=False,
4343
strategy: str = 'random'):
4444
```

examples/train_sage_ogbn_products.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def inference(self, x_all):
106106
)
107107
glt_dataset.init_node_labels(node_label_data=data.y)
108108

109-
device = torch.device(0)
109+
device = torch.device('cuda:0')
110110
# graphlearn_torch NeighborLoader
111111
train_loader = glt.loader.NeighborLoader(glt_dataset,
112112
[15, 10, 5],

graphlearn_torch/python/loader/link_loader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def __init__(
104104
edge_label_index: InputEdges = None,
105105
edge_label: Optional[torch.Tensor] = None,
106106
neg_sampling: Optional[NegativeSampling] = None,
107-
device: torch.device = torch.device(0),
107+
device: torch.device = torch.device('cuda:0'),
108108
edge_dir: Literal['out', 'in'] = 'out',
109109
**kwargs,
110110
):

graphlearn_torch/python/loader/link_neighbor_loader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def __init__(
122122
shuffle: bool = False,
123123
drop_last: bool = False,
124124
strategy: str = "random",
125-
device: torch.device = torch.device(0),
125+
device: torch.device = torch.device('cuda:0'),
126126
seed: Optional[int] = None,
127127
**kwargs,
128128
):

graphlearn_torch/python/loader/neighbor_loader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def __init__(
6868
with_edge: bool = False,
6969
with_weight: bool = False,
7070
strategy: str = 'random',
71-
device: torch.device = torch.device(0),
71+
device: torch.device = torch.device('cuda:0'),
7272
as_pyg_v1: bool = False,
7373
seed: Optional[int] = None,
7474
**kwargs

graphlearn_torch/python/loader/node_loader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def __init__(
5656
data: Dataset,
5757
node_sampler: BaseSampler,
5858
input_nodes: InputNodes,
59-
device: torch.device = torch.device(0),
59+
device: torch.device = torch.device('cuda:0'),
6060
**kwargs
6161
):
6262
self.data = data

graphlearn_torch/python/loader/subgraph_loader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def __init__(
6262
drop_last: bool = False,
6363
with_edge: bool = False,
6464
strategy: str = 'random',
65-
device: torch.device = torch.device(0),
65+
device: torch.device = torch.device('cuda:0'),
6666
seed: Optional[int] = None,
6767
**kwargs
6868
):

graphlearn_torch/python/sampler/neighbor_sampler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class NeighborSampler(BaseSampler):
4141
def __init__(self,
4242
graph: Union[Graph, Dict[EdgeType, Graph]],
4343
num_neighbors: Optional[NumNeighbors] = None,
44-
device: torch.device=torch.device('cuda', 0),
44+
device: torch.device=torch.device('cuda:0'),
4545
with_edge: bool=False,
4646
with_neg: bool=False,
4747
with_weight: bool=False,

0 commit comments

Comments
 (0)