question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Memory leak using TraceEnum_ELBO

See original GitHub issue

I noticed a major memory leak when training SVI using TraceEnum_ELBO. I initially noticed this in a custom model we are developing but then I found it seems a more general bug.

For example, it affects even the Pyro tutorials GMM example here. Where memory usage rapidly goes from a couple of hundred MBs to a many GBs very quickly!

I have run this Macbook Pro 2019 running MacOS 10.15. To replicate the issue is enough running the notebook linked.

I have tried to comment out the following lines and add a garbage collector call, that reduces the entity of the memory accumulation of one order of magnitude but does not solve the problem completely, which becomes particularly severe for large datasets.

# Register hooks to monitor gradient norms.
# gradient_norms = defaultdict(list)
# for name, value in pyro.get_param_store().named_parameters():
#     value.register_hook(lambda g, name=name: gradient_norms[name].append(g.norm().item()))

import gc
losses = []
for i in range(200000):
    loss = svi.step(data)
    #losses.append(loss)
    gc.collect()

(from this forum post)

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:2
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
OlaRonningcommented, Apr 28, 2022

Downgrading, as @qinqian suggests, also resolves #3014.

1reaction
qinqiancommented, Apr 27, 2022

I have noticed a GPU memory leaks too with Pyro 1.8.1+06911dc and PyTorch 1.11.0. Downgrade to Pyro 1.6.0 and PyTorch 1.8.0 works normally.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Finding and Fixing Memory Leaks in Python - BuzzFeed Tech
Reading bottom to top, this shows a trace to a line in the socket module where a memory allocation took place. With this...
Read more >
Identifying Memory Leaks Through Tracing - Percepio
The first method to detect a memory leak is to use the Tracealyzer Memory Heap Utilization view. This view can be accessed by...
Read more >
Finding memory leaks using Timing Captures - PIX on Windows
PIX Timing Captures include several analysis features aimed at making it easy to find memory leaks in your title.
Read more >
Determine the cause of a memory leak using LeanSentry's ...
In part 2, we'll explore how to use the LeanSentry Memory diagnostics report to determine the cause of a .NET memory leak.
Read more >
Understanding Memory Leaks in Java - Baeldung
A Memory Leak is a situation where there are objects present in the heap that are no longer used, but the garbage collector...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found