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

An error message #1

Open
zixiaoshuixin opened this issue Apr 19, 2022 · 1 comment
Open

An error message #1

zixiaoshuixin opened this issue Apr 19, 2022 · 1 comment

Comments

@zixiaoshuixin
Copy link

Hi,
I got an error message when I reproduced your project named "GNNStealing" and could you please tell how to solve it. Thank you so much!

when I executed "python train_target_model.py --dataset citeseer_full --target-model gat --num-hidden 256 --gpu 2", the error occurred. It seems that the "dgl.data.utils.split_dataset(..)" can't accept a parameter whose type is "DGLHeteroGraph" which has no length, so the error message is "TypeError: object of type 'DGLHeteroGraph' has no len()"

The error message in console is as follows:

[20:17:18] /opt/dgl/src/runtime/tensordispatch.cc:43: TensorDispatcher: dlopen failed: /etc/anaconda3/envs/gnn_model_stealing/lib/python3.9/site-packages/dgl/tensoradapter/pytorch/libtensoradapter_pytorch_1.10.2.so: cannot open shared object file: No such file or directory

Traceback (most recent call last):

File "/home/gpu/sunqin/GNNStealing-master/GNNStealing-master/code/train_target_model.py", line 55, in

train_g, val_g, test_g = split_graph(g, args.dataset, frac_list=[0.6, 0.2, 0.2])

File "/home/gpu/sunqin/GNNStealing-master/GNNStealing-master/code/src/utils.py", line 323, in split_graph

train_subset, val_subset, test_subset = dgl.data.utils.split_dataset(

File "/etc/anaconda3/envs/sunqin/lib/python3.9/site-packages/dgl/data/utils.py", line 76, in split_dataset

num_data = len(dataset)

TypeError: object of type 'DGLHeteroGraph' has no len()
error_message

@xinleihe
Copy link
Owner

This might be a hidden tiny bug of DGL=0.7

You may also test this example (which may reproduce the same error):

# https://docs.dgl.ai/generated/dgl.graph.html?highlight=dgl%20graph#dgl.graph
import dgl
import torch


# Source nodes for edges (2, 1), (3, 2), (4, 3)
src_ids = torch.tensor([2, 3, 4])
# Destination nodes for edges (2, 1), (3, 2), (4, 3)
dst_ids = torch.tensor([1, 2, 3])
g = dgl.graph((src_ids, dst_ids))

# https://docs.dgl.ai/generated/dgl.data.utils.split_dataset.html?highlight=split_dataset
a,b,c = dgl.data.utils.split_dataset(g, frac_list=[0.6, 0.2, 0.2])

To solve this problem, you may consider degrading DGL to a lower version like 0.6x or consider the tiny change:

# See also https://github.com/dmlc/dgl/blob/master/python/dgl/data/utils.py#L78
num_data = len(dataset) => num_data = len(dataset.nodes())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants