Skip to content

Huge memory consumption while generating model file #251

Closed
@vog

Description

@vog

I observe a huge memory consumption of Pyomo while generating a somewhat-bigger model file for IPOPT. Moreover, generating the model takes longer than running IPOPT to solve it.

However, the initial creation of the model objects using Pyomo expressions is fast and does not consume much memory.

How can I debug this? I suppose it might be the generation of derivatives, but I don't know how to verify this.

Regarding derivatives: Does Pyomo create simple-minded symbolic derivatives, or does it use some techniques of algorithmic differentiation (a.k.a. automatic differentiation, i.e. at least reusing common subexpressions and/or using AD reverse mode for gradient calculations).

Activity

qtothec

qtothec commented on Nov 7, 2017

@qtothec
Contributor
ghackebeil

ghackebeil commented on Nov 7, 2017

@ghackebeil
Member
jsiirola

jsiirola commented on Nov 7, 2017

@jsiirola
Member

Can you provide more detail about what you are doing? If you are working with an AbstractModel, then the initial model parse should be very fast and use little memory, with the time+memory coming when the model is actually constructed (that is, populated). There is also the possibility that the writer is duplicating a lot of the model (this happens, for example, when generating the canonical representation used by the LP writer -- something similar may be happening with the NL writer).

Can you share your model? Alternatively, can you run it with pyomo solve --report-timing and report the time breakdowns?

whart222

whart222 commented on Nov 8, 2017

@whart222
Member
vog

vog commented on Nov 9, 2017

@vog
Author

@ghackebeil I'm pretty sure the huge memory consumption occurs during generation of the nl file, but I'll verify that, just to be sure.

@jsiirola It's just a ConcreteModel, I haven't yet used AbstractModels.

@whart222 That sounds great. I'll provide a standalone example as soon as possible.

vog

vog commented on Nov 17, 2017

@vog
Author

The following test program is fully self-contained including the sample data:

test_model.py

Notes:

  • The critical part is the create_pyomo_model function.
  • @ghackebeil I must correct myself: The huge memory consumption happens indeed while building up the Pyomo model objects. Writing the test_model.nl file is fast and consumes almost no additional memory.
  • The program consumes 1.3 GB to create a Pyomo model that results in a 13 MB test_model.nl file, and takes quite some time for that.
  • The test program also contains the code around the model, just to give you an idea of the full picture: running the solver, converting the result, and running all that in a loop to push it out of local optima. But this is purely informational, that additional code is irrelevant to this issue.

Any suggestions how to improve speed and memory usage of that test program, or how to improve Pyomo to fix this issue?

Thanks in advance!

vog

vog commented on Nov 29, 2017

@vog
Author

Have you been able to take a look at the model?

Is there anything I can to do make the example program easier to analyze for you?

Any pointers on how to analyze the memory consumption issue on my own?

Regards,
Volker

jsiirola

jsiirola commented on May 8, 2020

@jsiirola
Member

Archived on the master Performance Proposals Issue (#1430). Closing this performance proposal until active development has begun.

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @jsiirola@vog@whart222@ghackebeil@qtothec

      Issue actions

        Huge memory consumption while generating model file · Issue #251 · Pyomo/pyomo