Floating licenses have a use limit, which is enforced by monitoring when tokens are issued/released. If all tokens are in use, any application attempting to use Gurobi to solve optimization problems will get the error “Request denied: use limit (N) exceeded”.
Compute Server and Instant Cloud are based on the client-server paradigm. As such, optimization jobs are issued to the optimization server by clients. Users may observe that a job is still running, even after the optimization task has finished.
One reason for the situations described above is that the user forgot to dispose of all models and environments at the end of the session. The steps to do so vary by programming language:
- C: Call GRBfreemodel() for each model, then call GRBfreeenv() for the Gurobi environment.
- C++: If you use pointers to GRBModel and GRBEnv objects, delete all GRBModel objects, then delete the GRBEnv object.
- .Java: Call GRBModel.dispose() on all GRBModel objects, then call GRBEnv.dispose() on the GRBEnv object.
- .NET: Call GRBModel.Dispose() on all GRBModel objects, then call GRBEnv.Dispose() on the GRBEnv object.
- Python:
- Gurobi 9.0.0 or newer: Call Model.dispose() on all Model objects. Then, if using custom-made environments, call Env.dispose() on all Env objects. Otherwise, call disposeDefaultEnv().
- Gurobi 8.1.1 or older: Delete all Model objects, delete all Env objects (if used), then call disposeDefaultEnv().
If you neglect to do this cleanup, the token or service may be temporarily unavailable for other applications.
Comments
2 comments
So, if I do not call dispose on all the models before disposing the environment, the license is not getting released? Could you clarify this for me?
Because it certainly does not throw an exception and I can still perform optimizations on the model after disposing the environment. This should be clarified in the documentation if that is the case. As it is worded right now,
it sounds to me, that I can just elect to not close the models first, if I'm not going to use them after disposing the environment.
Dear Patrick,
You are correct in assuming that the license may not be released after the environment is disposed of if there is a model that is still active.
You should always dispose of all models inside an environment before disposing of the environment as it is stated in the documentation. Otherwise, this can cause undefined behavior even is there is no error or warning message.
Best regards,
Matthias
Please sign in to leave a comment.