Skip to main content

Gurobi running out of memory in loop, but deleting environment every iteration

Awaiting user input

Comments

3 comments

  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    Hi Tenzin,

    Is the out-of-memory error happening during model building or during the solution process?

    Could you please try using the dispose() method instead of close()?

    Best regards, 
    Jaromił

    0
  • Tenzin Frijlink
    First Comment
    First Question

    Hi Jaromil.

    Thank you for the reply and suggestion! I tried using dispose instead of close, but it does not seem to matter. Also for my interest, according to the documentation close and dispose are equal methods, so what is the use of the one over the other?

    After checking I think the out-of-memory error occurs during model building. This is also where it slows down significantly after roughly 200 iterations. I also kept track of the the run times reported by Gurobi and they remain at a few seconds, even before running out of memory, so I am fairly sure now the issue is at the model building. 

    It gets stuck for a few minutes at this stage sometimes (and sometimes recovers and sometimes gives out of memory error):

    Set parameter Username
    Set parameter WLSAccessID
    Set parameter WLSSecret
    Set parameter LicenseID to [redacted]
    Academic license   [redacted]
    Set parameter TimeLimit to value 10
    Set parameter MIPGap to value 0.01

    Whereas in other iterations it goes straight to this and then goes through the solving process:

    Set parameter Username
    Set parameter WLSAccessID
    Set parameter WLSSecret
    Set parameter LicenseID to value  [redacted]
    Academic license [redacted]
    Set parameter TimeLimit to value 10
    Set parameter MIPGap to value 0.01
    Gurobi Optimizer version 11.0.1 build v11.0.1rc0 (win64 - Windows 10.0 (19045.2))

    CPU model: Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz, instruction set [SSE2|AVX|AVX2]
    Thread count: 4 physical cores, 8 logical processors, using up to 8 threads

     

    Thanks again,

    Tenzin

    0
  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    Hi Tenzin,

    Also for my interest, according to the documentation close and dispose are equal methods, so what is the use of the one over the other?

    This was just to check whether one or the other has a bug, but since both behave the same, it should be alright.

    Could you try computing how many variables and constraints you are trying to add in each iteration? In particular could you please compute the number of variables and constraints you are trying to add in the iteration when you seem to run into the memory issue? It is possible that your machine just runs out of memory due to model size. Could you also please try tracking the memory consumption to see whether the memory drops after an optimization process has finished. This is to make sure that the model and environment are properly disposed.

    Best regards, 
    Jaromił

    0

Please sign in to leave a comment.