I am getting following error while trying to assign features to DGL graph with tensorflow

DGLError: Cannot assign node feature “x” on device /job:localhost/replica:0/task:0/device:CPU:0 to a graph on device cpu. Call DGLGraph.to() to copy the graph to the same device.

A minimal example for reproducing the issue along with the graph structure:

import tensorflow as tf
import dgl
import tensorflow as tf
device = 'cpu'
g = dgl.graph(([0, 0, 0, 0, 0], [1, 2, 3, 4, 5]))
g = g.to(device)
g.ndata['x'] = tf.random.normal([6, 3])

My tf version is 2.8.0.
The above example works with PyTorch. I need to work with tf as most of my code is in tf. Any help to work around is highly appreciated.

Try use tensorflow as backend to run your script:

DGLBACKEND=tensorflow python <script.py>

and change device= 'cpu' to device='cpu:0'.

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