Device error when assigning node features

Hello, I am trying to reimplement some code based on dgl, where I keep getting into this error:

dgl._ffi.base.DGLError: Cannot assign node feature “event_indices” on device /job:localhost/replica:0/task:0/device:CPU:0 to a graph on device cpu. Call to copy the graph to the same device.

the operation that raises it is:

dgl_graph.ndata[‘event_indices’] = tf.constant(event_indices)

if I move the graph to CPU:0 with I get this error:

RuntimeError: Invalid device string: ‘/CPU:0’

The backend is tensorflow and the GPU is deactivated

os.environ[‘CUDA_VISIBLE_DEVICES’] = ‘-1’
os.environ[‘DGLBACKEND’] = ‘tensorflow’

If I try to enable the GPU, moving the data to it, or using a pytorch backend, I run in similar errors.

I would really appreciate your help as I am not very familiar with DGL!

Hi, ‘/CPU:0’ is not a valid device identity.
Just use ‘cpu’ for CPU memory and index int for gpu. More details can be found in Tensor Attributes — PyTorch 2.3 documentation.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.