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

[BUG] Quick start example code does not work #267

Open
rnyak opened this issue Oct 11, 2022 · 4 comments
Open

[BUG] Quick start example code does not work #267

rnyak opened this issue Oct 11, 2022 · 4 comments

Comments

@rnyak
Copy link

rnyak commented Oct 11, 2022

Hello, I installed the dgl and dglke as stated in the quick start and when I test the code below I get an error:

DGLBACKEND=pytorch dglke_train --model_name TransE_l2 --dataset FB15k --batch_size 1000 \
--neg_sample_size 200 --hidden_dim 400 --gamma 19.9 --lr 0.25 --max_step 500 --log_interval 100 \
--batch_size_eval 16 -adv --regularization_coef 1.00E-09 --test --num_thread 1 --num_proc 8
Reading train triples....
Finished. Read 483142 train triples.
Reading valid triples....
Finished. Read 50000 valid triples.
Reading test triples....
Finished. Read 59071 test triples.
|Train|: 483142
random partition 483142 edges into 8 parts
part 0 has 60393 edges
part 1 has 60393 edges
part 2 has 60393 edges
part 3 has 60393 edges
part 4 has 60393 edges
part 5 has 60393 edges
part 6 has 60393 edges
part 7 has 60391 edges
/usr/local/lib/python3.8/dist-packages/dgl/heterograph.py:72: DGLWarning: Recommend creating graphs by `dgl.graph(data)` instead of `dgl.DGLGraph(data)`.
  dgl_warning('Recommend creating graphs by `dgl.graph(data)`'
/usr/local/lib/python3.8/dist-packages/dgl/heterograph.py:83: DGLWarning: Keyword arguments ['readonly', 'multigraph', 'sort_csr'] are deprecated in v0.5, and can be safely removed in all cases.
  dgl_warning('Keyword arguments {} are deprecated in v0.5, and can be safely'
Traceback (most recent call last):
  File "/usr/local/bin/dglke_train", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.8/dist-packages/dglke/train.py", line 118, in main
    train_sampler_head = train_data.create_sampler(args.batch_size,
  File "/usr/local/lib/python3.8/dist-packages/dglke/dataloader/sampler.py", line 379, in create_sampler
    return EdgeSampler(self.g,
  File "/usr/local/lib/python3.8/dist-packages/dgl/contrib/sampling/sampler.py", line 683, in __init__
    self._sampler = _CAPI_CreateUniformEdgeSampler(
  File "dgl/_ffi/_cython/./function.pxi", line 293, in dgl._ffi._cy3.core.FunctionBase.__call__
  File "dgl/_ffi/_cython/./function.pxi", line 239, in dgl._ffi._cy3.core.FuncCall
dgl._ffi.base.DGLError: [18:41:08] /opt/dgl/include/dgl/packed_func_ext.h:117: Check failed: ObjectTypeChecker<TObjectRef>::Check(sptr.get()): Expected type graph.Graph but get graph.HeteroGraph
Stack trace:
  [bt] (0) /usr/local/lib/python3.8/dist-packages/dgl/libdgl.so(dmlc::LogMessageFatal::~LogMessageFatal()+0x4f) [0x7fc26d0546ef]
  [bt] (1) /usr/local/lib/python3.8/dist-packages/dgl/libdgl.so(dgl::GraphRef dgl::runtime::DGLArgValue::AsObjectRef<dgl::GraphRef>() const+0x264) [0x7fc26d36eab4]
  [bt] (2) /usr/local/lib/python3.8/dist-packages/dgl/libdgl.so(+0x521660) [0x7fc26d3d4660]
  [bt] (3) /usr/local/lib/python3.8/dist-packages/dgl/libdgl.so(+0x522234) [0x7fc26d3d5234]
  [bt] (4) /usr/local/lib/python3.8/dist-packages/dgl/libdgl.so(DGLFuncCall+0x48) [0x7fc26d31c118]
  [bt] (5) /usr/local/lib/python3.8/dist-packages/dgl/_ffi/_cy3/core.cpython-38-x86_64-linux-gnu.so(+0x16083) [0x7fc26ca15083]
  [bt] (6) /usr/local/lib/python3.8/dist-packages/dgl/_ffi/_cy3/core.cpython-38-x86_64-linux-gnu.so(+0x1686b) [0x7fc26ca1586b]
  [bt] (7) /usr/bin/python3(_PyObject_MakeTpCall+0x296) [0x5f74f6]
  [bt] (8) /usr/bin/python3(_PyEval_EvalFrameDefault+0x59b5) [0x570d55]

is there a quick fix to that error? thanks.

@PoloWitty
Copy link

I get the same error, too! So I tried to use another version of dgl and dgl-ke to fix this. After I try to install dgl-ke from source and use dgl of version dgl-cu113 0.8.0. The code report another error:

Traceback (most recent call last):
  File "/anaconda/envs/dgl-ke/bin/dglke_train", line 33, in <module>
    sys.exit(load_entry_point('dglke==0.1.0.dev0', 'console_scripts', 'dglke_train')())
  File "/anaconda/envs/dgl-ke/bin/dglke_train", line 25, in importlib_load_entry_point
    return next(matches).load()
  File "/anaconda/envs/dgl-ke/lib/python3.10/importlib/metadata/__init__.py", line 171, in load
    module = import_module(match.group('module'))
  File "/anaconda/envs/dgl-ke/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/anaconda/envs/dgl-ke/lib/python3.10/site-packages/dglke-0.1.0.dev0-py3.10.egg/dglke/train.py", line 23, in <module>
  File "/anaconda/envs/dgl-ke/lib/python3.10/site-packages/dglke-0.1.0.dev0-py3.10.egg/dglke/dataloader/__init__.py", line 21, in <module>
  File "/anaconda/envs/dgl-ke/lib/python3.10/site-packages/dglke-0.1.0.dev0-py3.10.egg/dglke/dataloader/sampler.py", line 23, in <module>
ModuleNotFoundError: No module named 'dgl.backend'

@PoloWitty
Copy link

Oh! I find a way to solve this bug thanks to @guillaume-be's PR.

The step is as followed:

# install dgl-cu113 of version 0.8.2
pip install dgl-cu113==0.8.2 dglgo -f https://data.dgl.ai/wheels/repo.html

# install dgl-ke using newest version (the version in pypi hasn't been updated to the newest one on github)
git clone https://github.com/awslabs/dgl-ke.git
cd dgl-ke/python
python setup.py install

I think this might be able to solve your issuse, too.

@AndroidSheepy
Copy link

Oh! I find a way to solve this bug thanks to @guillaume-be's PR.

The step is as followed:

# install dgl-cu113 of version 0.8.2
pip install dgl-cu113==0.8.2 dglgo -f https://data.dgl.ai/wheels/repo.html

# install dgl-ke using newest version (the version in pypi hasn't been updated to the newest one on github)
git clone https://github.com/awslabs/dgl-ke.git
cd dgl-ke/python
python setup.py install

I think this might be able to solve your issuse, too.

Please notice that if you don't have the root privilege, you should run "python setup.py install --user".

@PoloWitty
Copy link

BTW, I made a docker image and readme for easier usage. Feel free to use it if this is helpful to anyone who see this :)
https://hub.docker.com/repository/docker/yangzhep/kge/general

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

3 participants