NVIDIA / modulus-launch

Repo of optimized training recipes for accelerating PyTorch workflows of AI driven surrogates for physical systems
Apache License 2.0
56 stars 27 forks source link

vortex_shedding_mgn model input DGLGraph instead of tensor #34

Closed giorgionicola closed 1 year ago

giorgionicola commented 1 year ago

In the example vortex_shedding_mgn/train.py at line 147 the graph created via DGL is fed to the network that expect a Tensor.

here attached the error:

File "train.py", line 147, in <module> \\
    loss = trainer.train(graph)
  File "train.py", line 92, in train
    loss = self.forward(graph)
  File "train.py", line 125, in forward
    pred = self.model(graph.ndata["x"], graph.edata["x"], graph)
  File "/home/mullis/venv/modulus/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/home/mullis/venv/modulus/lib/python3.8/site-packages/modulus/models/meshgraphnet/meshgraphnet.py", line 148, in forward
    edge_features = self.edge_encoder(edge_features)
  File "/home/mullis/venv/modulus/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/home/mullis/venv/modulus/lib/python3.8/site-packages/modulus/models/meshgraphnet/meshgraphnet.py", line 187, in forward
    return self.mlp(x)
  File "/home/mullis/venv/modulus/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/home/mullis/venv/modulus/lib/python3.8/site-packages/torch/nn/modules/container.py", line 217, in forward
    input = module(input)
  File "/home/mullis/venv/modulus/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/home/mullis/venv/modulus/lib/python3.8/site-packages/torch/nn/modules/linear.py", line 114, in forward
    return F.linear(input, self.weight, self.bias)
TypeError: linear(): argument 'input' (position 1) must be Tensor, not DGLGraph
giorgionicola commented 1 year ago

Hi, I have managed to run the example by simply reverting only the file train.py to the previous version. Specifically, I have changed line 125 from

pred = self.model(graph.ndata["x"], graph.edata["x"], graph)

to

pred = self.model(graph, graph.ndata["x"], graph.edata["x"])

NickGeneva commented 1 year ago

HI @giorgionicola

Thank you for reporting this, as well as the follow up. Is this with the pip install of modulus core? I believe the updated example is using the version present on the main branch. Consider a source install to use the latest network.

mnabian commented 1 year ago

Hi @giorgionicola , just checking to see if the issue is resolved? As Nick mentioned, this has been fixed in the latest version of the main branch, and a source install should work.

mnabian commented 1 year ago

Closing as resolved. Please reopen if the issue persists.