Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not Freeing Gurobi Environment Between Calculations #43

Closed
philipithomas opened this issue Sep 25, 2015 · 4 comments
Closed

Not Freeing Gurobi Environment Between Calculations #43

philipithomas opened this issue Sep 25, 2015 · 4 comments

Comments

@philipithomas
Copy link

Background

We are using Gurobi.jl with JuMP.jl to run calculations. In a given script, we will run ~100 models. Rather than run the calculations locally, the Gurobi model connects to a Gurobi computation server. (If you're unfamiliar - the only change locally is that the license file says "instead of a license key, I actually point to a server". Everything else is basically the same).

Issue

When running the script, calculations are blocked until they complete on the server. However, when the calculation appears to have completed locally (because it receives a convergent result) - the computation server still shows it as a running calculation. The calculation is not consuming any resources, but it blocks additional calculations and causes the next calculation to block. So, if we limit the computation server to 2 simultaneous calculations - then two begin processing, finish, but continue to block, and all subsequent calculations enter a queued state. They do not get calculated until the original calculations time out.

Proposed Fix

Can we explicitly free the Gurobi environment after a calculation completes? Is there a way to explicitely do this using the JuMP interface?

Debugging

If you need a computation server for testing, I can spin one up - ping me (philip at staffjoy.com)

Gurobi Support Input

We have different APIs from which you can call Gurobi (C, C++, Java, Python,...). In some of these APIs there are explicit methods for freeing a Gurobi environment, in some of them you just delete the GRBEnv object. If you are not using one of our APIs there is no way to free the environment except for killing the complete process.

As you are using Julia JuMP for calling Gurobi, I don't see a way for you do free the environment, except for changing the JuMP code. If this is what you want to do, just tell me which API they use (I guess C or C++, for C there is a function called GRBfreeEnv: http://www.gurobi.com/documentation/6.0/refman/c_grbfreeenv.html).

Our complete documentation can be found here: http://www.gurobi.com/documentation/
There are also reference manuals for the different programming languages.

@mlubin
Copy link
Member

mlubin commented Sep 25, 2015

The gurobi model should be freed when the JuMP model goes out of scope and is garbage collected. You could try forcing this by calling gc().

@philipithomas
Copy link
Author

@mlubin This worked perfectly. Thanks so much.

@EmiFej
Copy link

EmiFej commented Jun 13, 2023

Hi @mlubin and @philipithomas . I'm not sure if I have the same issue as @philipithomas, but in my case I run a snakemake file with multiple jobs (lp file creation, solving, etc.), one of which is to use gurobi_cl to solve an lp file. It solves the model and provides me with a log of the work, see below:

Iteration    Objective       Primal Inf.    Dual Inf.      Time
  359928    2.6165717e+06   0.000000e+00   1.149257e+02    951s
  359949    2.6165717e+06   2.522881e-05   4.417873e+07    957s
Extra simplex iterations after uncrush: 4
  359953    2.6165717e+06   0.000000e+00   0.000000e+00    957s

Solved in 359953 iterations and 957.17 seconds (2210.05 work units)
Optimal objective  2.616571710e+06
Warning: environment still referenced so free is deferred (Continue to use WLS)

However, as you see in the last row, I'm getting an error. This causes the workflow not to write out my solution file, under an error "MissingOutputException in rule run_model in file... Job 3 completed successfully, but some output files are missing. Missing files after 200 seconds. This might be due to filesystem latency. If that is the case, consider to increase the wait time with --latency-wait".

This is after I set the "--latency-wait" option to 200 seconds. Is there anything I can add to the snakemake file that could specify to gurobi that when the job is over to free the environment?

Looking forward to your comments! :)

@odow
Copy link
Member

odow commented Jun 13, 2023

@EmiFej please contact Gurobi support directly: https://www.gurobi.com/support/gurobi-experts/

The Gurobi.jl repository is for the Julia wrapper of Gurobi, which is not an officially supported product, and you don't appear to be using JuMP or Gurobi.jl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants