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

Huge memory consumption while generating model file #251

Closed
vog opened this issue Nov 7, 2017 · 8 comments
Closed

Huge memory consumption while generating model file #251

vog opened this issue Nov 7, 2017 · 8 comments

Comments

@vog
Copy link

vog commented Nov 7, 2017

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).

@qtothec
Copy link
Contributor

qtothec commented Nov 7, 2017 via email

@ghackebeil
Copy link
Member

ghackebeil commented Nov 7, 2017 via email

@jsiirola
Copy link
Member

jsiirola commented Nov 7, 2017

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
Copy link
Member

whart222 commented Nov 8, 2017 via email

@vog
Copy link
Author

vog commented Nov 9, 2017

@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
Copy link
Author

vog commented Nov 17, 2017

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
Copy link
Author

vog commented Nov 29, 2017

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
Copy link
Member

jsiirola commented May 8, 2020

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

@jsiirola jsiirola closed this as completed May 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants