dmlc / dgl

Python package built to ease deep learning on graph, on top of existing DL frameworks.
http://dgl.ai
Apache License 2.0
13.47k stars 3.01k forks source link

【DGLError】dgl._ffi.base.DGLError:Check failed: fs: Filename is invalid #1826

Closed ChloeWongxt closed 4 years ago

ChloeWongxt commented 4 years ago

dgl._ffi.base.DGLError:Check failed: fs: Filename is invalid

Run link prediction example fails.

When i test my code

There are some troubles with it.

I don`t have any idea with what happens. Could you help me? thanks a lot.

paper`s name:GCC: Graph Contrastive Coding for Graph Neural NetworkPre-Training paper:https://arxiv.org/abs/2006.09963 code:https://github.com/THUDM/GCC

Error

(GCC01) chloe@chloe-MS-7A74:~/Documents/00 Work/02 Xovee/01 Code/GCC$ bash scripts/pretrain.sh 0 --batch-size 256
Using backend: pytorch
Namespace(alpha=0.999, aug='1st', batch_size=256, beta1=0.9, beta2=0.999, clip_norm=1.0, cv=False, dataset='dgl', degree_embedding_size=16, epochs=100, exp='Pretrain', finetune=False, fold_idx=0, freq_embedding_size=16, gpu=0, hidden_size=64, learning_rate=0.005, load_path=None, lr_decay_epochs=[120, 160, 200], lr_decay_rate=0.0, max_degree=512, max_edge_freq=16, max_node_freq=16, moco=False, model='gin', model_folder='saved/Pretrain_moco_False_dgl_gin_layer_5_lr_0.005_decay_1e-05_bsz_256_hid_64_samples_2000_nce_t_0.07_nce_k_32_rw_hops_256_restart_prob_0.8_aug_1st_ft_False_deg_16_pos_32_momentum_0.999', model_name='Pretrain_moco_False_dgl_gin_layer_5_lr_0.005_decay_1e-05_bsz_256_hid_64_samples_2000_nce_t_0.07_nce_k_32_rw_hops_256_restart_prob_0.8_aug_1st_ft_False_deg_16_pos_32_momentum_0.999', model_path='saved', momentum=0.9, nce_k=32, nce_t=0.07, norm=True, num_copies=6, num_layer=5, num_samples=2000, num_workers=12, optimizer='adam', positional_embedding_size=32, print_freq=10, readout='avg', restart_prob=0.8, resume='', rw_hops=256, save_freq=1, seed=0, set2set_iter=6, set2set_lstm_layer=3, subgraph_size=128, tb_folder='tensorboard/Pretrain_moco_False_dgl_gin_layer_5_lr_0.005_decay_1e-05_bsz_256_hid_64_samples_2000_nce_t_0.07_nce_k_32_rw_hops_256_restart_prob_0.8_aug_1st_ft_False_deg_16_pos_32_momentum_0.999', tb_freq=250, tb_path='tensorboard', weight_decay=1e-05)
Use GPU: 0 for training
setting random seeds
before construct dataset 6.249996185302734
Traceback (most recent call last):
  File "train.py", line 818, in <module>
    main(args)
  File "train.py", line 555, in main
    num_copies=args.num_copies
  File "/home/chloe/Documents/00 Work/02 Xovee/01 Code/GCC/gcc/datasets/graph_dataset.py", line 58, in __init__
    graph_sizes = dgl.data.utils.load_labels(dgl_graphs_file)[
  File "/home/chloe/anaconda3/envs/GCC01/lib/python3.7/site-packages/dgl/data/graph_serialize.py", line 172, in load_labels
    metadata = _CAPI_DGLLoadGraphs(filename, [], True)
  File "dgl/_ffi/_cython/./function.pxi", line 287, in dgl._ffi._cy3.core.FunctionBase.__call__
  File "dgl/_ffi/_cython/./function.pxi", line 222, in dgl._ffi._cy3.core.FuncCall
  File "dgl/_ffi/_cython/./function.pxi", line 211, in dgl._ffi._cy3.core.FuncCall3
  File "dgl/_ffi/_cython/./base.pxi", line 155, in dgl._ffi._cy3.core.CALL
dgl._ffi.base.DGLError: [21:41:01] /opt/dgl/src/graph/graph_serialize.cc:193: Check failed: fs: Filename is invalid
Stack trace:
  [bt] (0) /home/chloe/anaconda3/envs/GCC01/lib/python3.7/site-packages/dgl/libdgl.so(dmlc::LogMessageFatal::~LogMessageFatal()+0x22) [0x7fbe9e1ec782]
  [bt] (1) /home/chloe/anaconda3/envs/GCC01/lib/python3.7/site-packages/dgl/libdgl.so(dgl::serialize::LoadDGLGraphs(std::string const&, std::vector<unsigned long, std::allocator<unsigned long> >, bool)+0xe7c) [0x7fbe9e859a5c]
  [bt] (2) /home/chloe/anaconda3/envs/GCC01/lib/python3.7/site-packages/dgl/libdgl.so(+0xd1f0eb) [0x7fbe9e85a0eb]
  [bt] (3) /home/chloe/anaconda3/envs/GCC01/lib/python3.7/site-packages/dgl/libdgl.so(DGLFuncCall+0x52) [0x7fbe9e7f46e2]
  [bt] (4) /home/chloe/anaconda3/envs/GCC01/lib/python3.7/site-packages/dgl/_ffi/_cy3/core.cpython-37m-x86_64-linux-gnu.so(+0x19cdb) [0x7fbef63a5cdb]
  [bt] (5) /home/chloe/anaconda3/envs/GCC01/lib/python3.7/site-packages/dgl/_ffi/_cy3/core.cpython-37m-x86_64-linux-gnu.so(+0x1a25b) [0x7fbef63a625b]
  [bt] (6) python(_PyObject_FastCallKeywords+0x48b) [0x55db603c900b]
  [bt] (7) python(_PyEval_EvalFrameDefault+0x49b6) [0x55db6042d186]
  [bt] (8) python(_PyFunction_FastCallKeywords+0xfb) [0x55db603c120b]

Environment

scikit-learn==0.20.3 scipy==1.4.1 coverage==4.5.4 coveralls==1.9.2 black==19.3b0 pytest==5.3.2 networkx==2.3 numpy==1.18.2 matplotlib==3.1.0 seaborn==0.9.0 tqdm==4.43.0 tensorboard_logger==0.1.0

torch~=1.5.1 dgl~=0.4.3.post2 pandas~=1.0.5 requests~=2.24.0 psutil~=5.7.2 joblib~=0.16.0

Python:3.7 PyTorch 1.5.1 DGL 0.4.1 rdkit=2019.09.2.

yzh119 commented 4 years ago

Hi, could you please try latest version of DGL (0.4.3), which updates the graph serialization module.

VoVAllen commented 4 years ago

Hi,

May I know which code are you running?

ChloeWongxt commented 4 years ago

Hi, could you please try latest version of DGL (0.4.3), which updates the graph serialization module.

Thanks for your answer. But it still doesnt work when I update to the lastest version of DGL(0.4.3). The DGLs version of my environment is 0.4.3.post2

ChloeWongxt commented 4 years ago

Hi, could you please try latest version of DGL (0.4.3), which updates the graph serialization module.

Thanks for your answer. But it still doesnt work when I update to the lastest version of DGL(0.4.3). The DGLs version of my environment is 0.4.3.post2

the code`link is https://github.com/THUDM/GCC

VoVAllen commented 4 years ago

Did you properly download the pre-training dataset at https://github.com/THUDM/GCC/blob/master/GETTING_STARTED.md? This error seems the filename is not found.

classicsong commented 4 years ago

Can you add some print at L58 at gcc/datasets/graph_dataset.py and verify the dgl_graphs_file is in the right location?

ChloeWongxt commented 4 years ago

I finally deal with this question.yea~~~

line 554 of file train.py the datasets` path is

dgl_graphs_file="./data_bin/dgl/small.bin",

but when we download the pretraining dataset as the following step

python scripts/download.py --url https://drive.google.com/open?id=1JCHm39rf7HAJSp-1755wa32ToHCn2Twz --path data --fname small.bin
# For regions where Google is not accessible, use
# python scripts/download.py --url https://cloud.tsinghua.edu.cn/f/b37eed70207c468ba367/?dl=1 --path data --fname small.bin

the pretraing file will be ./data/small.bin

so the solution of this question is that you should new folder as this path ./data_bin/dgl/ and remove the file small.bin in this new folder, Or you can change the line 554 of file train.py as following

dgl_graphs_file="./data/small.bin"

I have spent 4 days to deal with it, even though this is a small question. But i am so happy to deal with this question. Because at the process of dealing with it, i improved a lot.