-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
to() got an unexpected keyword argument 'non_blocking' for DGLGraph #2637
Comments
Hi! thanks for your contribution!, great first issue! |
Having the same problem; it's because dgl.DGLGraph().to('cuda', non_blocking=True) Here's my temporary solution: class LightningDGLGraph(DGLGraph):
def to(self, ctx, *args, **kwargs):
return super().to(torch.device(ctx))
g = LightningDGLGraph()
g.to('cuda', non_blocking=True) Works, but probably not ideal. |
Hi, I wonder how this will work if using dgl.batch? the class type they return to you is a Ok, they also have this quick fix here: dmlc/dgl#1600.
|
It seems to work for me for now. |
Just saw your edit. |
For a clean solution in Lightning, override this model hook and call .to() yourself on the graph object. |
Regarding ddp, is DGLGraph supposed to work with that (I mean in plain pytorch)? I don't think it can work with scatter and gather. |
@awaelchli Is this supposed to be overridden in the model? It doesn't seem to get called for me in a distributed setting. |
@jacobdanovitch Yes, this hook only works for single gpu, because in distributed we need to scatter and gather a batch, and if it is a custom object we don't know how to do that. For this, you would have to define your own DistributedDataParallel module and configure it in the configure_ddp model hook. We should probably update the docs regarding that. |
🐛 Bug
To Reproduce
I use dgl library to make a gnn and batch the DGLGraph.
No problem during training, but in test, I got a TypeError: to() got an unexpected keyword argument 'non_blocking'
<class 'dgl.graph.DGLGraph'> .to() function has no keyword argument 'non_blocking'
Code sample
Expected behavior
Environment
Additional context
The text was updated successfully, but these errors were encountered: