pythonpytorchpytorch-geometric

Found dtype Double but expected Float


BLUF:

data.x.dtype = torch.float64 data.edge_index.dtype = torch.float64' 'data.Utility.dtype = torch.float64

but when I run

loss = F.mse_loss(model(graph.x.to(torch.float), graph.edge_index, graph.batch), graph.Utility)

I get:

Traceback (most recent call last):
  File "/home/polar/venv/pygeo/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 3526, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-58-52a0569421b1>", line 1, in <module>
    loss.backward()
  File "/home/polar/venv/pygeo/lib/python3.10/site-packages/torch/_tensor.py", line 487, in backward
    torch.autograd.backward(
  File "/home/polar/venv/pygeo/lib/python3.10/site-packages/torch/autograd/__init__.py", line 200, in backward
    Variable._execution_engine.run_backward(  # Calls into the C++ engine to run the backward pass
RuntimeError: Found dtype Double but expected Float

I even did model = model.to(dtype=torch.float) as the other ones state. Still doesn't work!

Please don't comment, write an answer so I can mark it as the answer, thank you.


Solution

  • This looks similar to package/python version dependency issues I've hit in the past.

    Looks like you have a package called "torch" and are running python 3.10.

    Might be worth checking which version of torch you've got and checking the package's docs for which python versions are supported, then up or downgrading either the package or your python version so they match.

    Hope it helps!