Possible memory leak when calling solver.run multiple times
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 76
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 1
Description
I am trying to solve a problem where `solver.run` is called multiple times to minimize a series of functions while varying a parameter. Using `memory_profiler` I can see that the allocated memory increases each time the function `solver.run` is called and never decreases.
Here is a minimal example to reproduce the issue:
import jax.numpy as jnp
import jaxopt
from memory_profiler import profile
@profile
def optimize(min):
def obj(x, min):
return jnp.square(x-min).sum()
x0 = jnp.zeros(1)
mm = jnp.array(min)
solver = jaxopt.LBFGS(obj, maxiter=100)
x = solver.run(x0, min=mm).params[0]
print(x)
for i in range(10):
optimize(i)
And here is the corresponding plot of the allocated memory:

Can you please confirm the issue or provide a solution for that? Thanks. Alessandro
Contributor guide
Assessment
This issue has not been assessed yet.