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 in cp.sum(list) #2385

Closed
xuzhiying9510 opened this issue Mar 16, 2024 · 1 comment · Fixed by #2428
Closed

Huge memory consumption in cp.sum(list) #2385

xuzhiying9510 opened this issue Mar 16, 2024 · 1 comment · Fixed by #2428

Comments

@xuzhiying9510
Copy link

xuzhiying9510 commented Mar 16, 2024

Describe the bug
Huge memory consumption in cp.sum(list). I know cp.sum(cp.hstack(list)) solves the problem, but can cp.sum(list) be improved?

To Reproduce

x = [cp.Variable() for i in range(100000)]
expr = cp.sum(x)

Output
expr = cp.sum(x) uses > 30G memory and is super slow.

Version

  • OS: Ubuntu 18.04.3 LTS
  • CVXPY Version: 1.1.24
@rileyjmurray
Copy link
Collaborator

Thanks for reporting this, @xuzhiying9510!

You appear to be using an outdated version of cvxpy, but I can confirm that the issue occurs with version 1.4 as well. I also tried

expr = cp.sum([cp.Variable(), cp.Variable()] + [0.00001 * i for i in range(2,100000)])

and found that it consumed as similar amount of memory.

We'd need more detailed performance profiling to see what can be done in this situation. I'm not terribly optimistic that this could be accelerated without moving some of cvxpy's logic into C/C++.

@phschiele, @Transurgeon, could you take a look?

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

Successfully merging a pull request may close this issue.

2 participants