everyone. I am beginner in coding and non-major in it.
I run the code by python on Window WSL(Ubuntu).
In running the code, dgl was run and it has error like 'AttributeError: 'numpy.ndarray' object has no attribute 'device''
More detail:
AttributeError: Caught AttributeError in DataLoader worker process 0.
Original Traceback (most recent call last):
File "~/lib/python3.8/site-packages/torch/utils/data/_utils/worker.py", line 302, in _worker_loop
data = fetcher.fetch(index)
File "~/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 49, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "~/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 49, in <listcomp>
data = [self.dataset[idx] for idx in possibly_batched_index]
File "~/interactive_se3/OpenFold2-toy_se3/src/Dataset.py", line 67, in __getitem__
G.ndata['x'] = r.astype(np.float32)
File "~/lib/python3.8/site-packages/dgl/view.py", line 90, in __setitem__
self._graph._set_n_repr(self._ntid, self._nodes, {key: val})
File "~/lib/python3.8/site-packages/dgl/heterograph.py", line 4121, in _set_n_repr
if F.context(val) != self.device:
File "~/lib/python3.8/site-packages/dgl/backend/pytorch/tensor.py", line 80, in context
return input.device
AttributeError: 'numpy.ndarray' object has no attribute 'device'
I found the error line and I got the reason of error. The module 'ndarray.py' in dgl package (\lib\python3.8\site-packages\dgl) actually doesn't have 'device' attribute as the error said.
After I found the reason of error, 'no attribute',
I changed the code like that: from:
from ... import ndarray as nd
to:
from numpy import ndarray as nd
It work!
But I faced again the error like 'AttributeError: type object 'numpy.ndarray' has no attribute 'from_dlpack''
More detail:
AttributeError: Caught AttributeError in DataLoader worker process 0.
Original Traceback (most recent call last):
File "~/lib/python3.8/site-packages/torch/utils/data/_utils/worker.py", line 302, in _worker_loop
data = fetcher.fetch(index)
File "~/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 49, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "~/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 49, in <listcomp>
data = [self.dataset[idx] for idx in possibly_batched_index]
File "~/OpenFold2-toy_se3/src/Dataset.py", line 65, in __getitem__
G = dgl.DGLGraph((src, dst))
File "~/lib/python3.8/site-packages/dgl/heterograph.py", line 76, in __init__
gidx = heterograph_index.create_unitgraph_from_coo(
File "~/lib/python3.8/site-packages/dgl/heterograph_index.py", line 1160, in create_unitgraph_from_coo
F.to_dgl_nd(row), F.to_dgl_nd(col),
File "~/lib/python3.8/site-packages/dgl/backend/__init__.py", line 128, in to_dgl_nd
return zerocopy_to_dgl_ndarray(data)
File "~/lib/python3.8/site-packages/dgl/backend/pytorch/tensor.py", line 344, in zerocopy_to_dgl_ndarray
return nd.from_dlpack(dlpack.to_dlpack(data.contiguous()))
AttributeError: type object 'numpy.ndarray' has no attribute 'from_dlpack'
Yes, now the 'from_dlpack' attribute was not in the numpy packge.
I serached what is 'from_dlpack',and 'from_dlpack' is torch attribute (torch.from_dlpack).
And 'device' attribute is also torch attribute.
What is wrong with the dgl package? Why the code try to find the 'device' and 'from_dlpack' attribute from numpy and how can I fix it?