Open Tifus15 opened 1 year ago
Please check #2 and try the branch beta.
I switched to beta and It doesn't help. I have a test code which it use torchdiffeq adjoint_odeint with rk4. When I switch to your symplectic integrator I get same error as before. Strange is that for euler I get another error now, at master it worked:
Traceback (most recent call last):
File "/home/andric/Desktop/hamiltonian-neural-dynamics/Masterthesis/numerical integration/neural_numerical.py", line 101, in
I set up a new environment with Python v3.7.3 using Anaconda and installed PyTorch v1.7.1 and this repository. I tried running the code attached at the end of this comment, and confirmed that it works without any errors.
As mentioned in #2, the following error occurs with PyTorch v1.13.1 and the master branch, but did not with the beta branch:
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu! (when checking argument for argument other in method wrapper_nextafter)
Please try changing the versions of Python or PyTorch.
import torch
import torch.nn as nn
from torch_symplectic_adjoint import odeint, odeint_adjoint, odeint_symplectic_adjoint
device = "cuda"
N = 5
B = 100
A = torch.randn(N, N, device=device)
class Lambda(nn.Module):
def forward(self, t, y):
return torch.mm(y, A)
f = Lambda().to(device)
x0 = torch.randn(B, N, device=device)
t = torch.arange(0, 200, device=device) / 200
y_euler = odeint(f, x0, t, method="euler")
y_rk4 = odeint(f, x0, t, method="rk4")
y_dopri5 = odeint(f, x0, t, method="dopri5")
y_euler = odeint_adjoint(f, x0, t, method="euler")
y_rk4 = odeint_adjoint(f, x0, t, method="rk4")
y_dopri5 = odeint_adjoint(f, x0, t, method="dopri5")
y_euler = odeint_symplectic_adjoint(f, x0, t, method="euler")
y_rk4 = odeint_symplectic_adjoint(f, x0, t, method="rk4")
y_dopri5 = odeint_symplectic_adjoint(f, x0, t, method="dopri5")
Hello I was measuring the performance between of torchdiffeq odeint and your symplectic odeint and I get following error in my code segment:
On the cuda device the euler works without issues but I get at rk4 and dopri5 an error that the matrices are not on same device. normal odeint from torchdiffeq doen't show this behaviour.
On cpu is all good.
The error message: