Affected versions: v11.0.0, v11.0.1, v11.0.2, v11.0.3
Resolved in version: Gurobi v12.0.0
In certain circumstances a memory leak can occur when using gurobipy 11.0.x and Python 3.12. The issue only affects Python 3.12, earlier version are not affected. If you encounter unexpectedly high memory use the most appropriate workaround is to downgrade your Python version to 3.11 or earlier.
Further information for numpy users
The memory leak is most likely to be noticeable when creating large numpy arrays of Gurobi variables, for example:
import gurobipy as gp
import numpy as np
with gp.Env() as env, gp.Model(env=env) as model:
x = model.addVars(1_000_000)
arr = np.array(list(x.values()) # Causes high memory usage
A workaround in this specific case is to use np.fromiter to construct the array:
import gurobipy as gp
import numpy as np
with gp.Env() as env, gp.Model(env=env) as model:
x = model.addVars(1_000_000)
arr = np.fromiter(x.values())
The issue does not impact the creation of MVar's directly through Gurobi's matrix API, so addMVar can be safely used.
Further information for cvxpy users
We're aware that using cvxpy with Gurobi also triggers the memory leak and have submitted a patch to the cvxpy developers.
Comments
0 comments
Article is closed for comments.