Error when import dgl


AttributeError Traceback (most recent call last)
in
1 import torch
----> 2 import dgl
3 import networkx as nx
4
5 import cv2

~/anaconda3/envs/tvm/lib/python3.7/site-packages/dgl/init.py in
6 # Need to ensure that the backend framework is imported before load dgl libs,
7 # otherwise weird cuda problem happens
----> 8 from .backend import load_backend, backend_name
9
10 from . import function

~/anaconda3/envs/tvm/lib/python3.7/site-packages/dgl/backend/init.py in
72
73
—> 74 load_backend(get_preferred_backend())
75
76

~/anaconda3/envs/tvm/lib/python3.7/site-packages/dgl/backend/init.py in load_backend(mod_name)
22 def load_backend(mod_name):
23 print(‘Using backend: %s’ % mod_name, file=sys.stderr)
—> 24 mod = importlib.import_module(’.%s’ % mod_name, name)
25 thismod = sys.modules[name]
26 for api in backend.dict.keys():

~/anaconda3/envs/tvm/lib/python3.7/importlib/init.py in import_module(name, package)
125 break
126 level += 1
–> 127 return _bootstrap._gcd_import(name[level:], package, level)
128
129

~/anaconda3/envs/tvm/lib/python3.7/site-packages/dgl/backend/pytorch/init.py in
----> 1 from .tensor import *

~/anaconda3/envs/tvm/lib/python3.7/site-packages/dgl/backend/pytorch/tensor.py in
8 from torch.utils import dlpack
9
—> 10 from … import ndarray as nd
11 from … import kernel as K
12 from …function.base import TargetCode

~/anaconda3/envs/tvm/lib/python3.7/site-packages/dgl/ndarray.py in
13
14 from ._ffi.object import register_object, ObjectBase
—> 15 from ._ffi.function import _init_api
16 from ._ffi.ndarray import DGLContext, DGLType, NDArrayBase
17 from ._ffi.ndarray import context, empty, from_dlpack, numpyasarray

~/anaconda3/envs/tvm/lib/python3.7/site-packages/dgl/_ffi/function.py in
14 raise ImportError()
15 if sys.version_info >= (3, 0):
—> 16 from ._cy3.core import _set_class_function, _set_class_module
17 from ._cy3.core import FunctionBase as _FunctionBase
18 from ._cy3.core import convert_to_dgl_func

dgl/_ffi/_cython/./object.pxi in init dgl._ffi._cy3.core()

AttributeError: type object ‘dgl._ffi._cy3.core.ObjectBase’ has no attribute ‘reduce_cython

How did you install dgl?

conda install -c dglteam dgl-cuda10.0

This seems to be an issue related to Cython. You may find the discussions here helpful:

thank you ,I have solved the problem