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

[BUG] Usage of Dictionaries will cause a "Memory Leak" in Multi-Node Environment #2448

Open
MathiasBaumgartinger opened this issue Dec 5, 2024 · 2 comments
Assignees
Labels
datasets Geospatial or benchmark datasets
Milestone

Comments

@MathiasBaumgartinger
Copy link
Contributor

Description

I am working on a SLURM multi-node architecture where each node has two GPUs. In such a multi-process environment, the usage of a dictionaries (i.e. samples provided by torchgeo-datamodules) will cause -- quote -- "copy-on-access problem of forked python processes". See pytorch/pytorch#13246 (comment) for more information. This refcounting problem leads to an ever increasing usage of memory, which will sooner or later cause the process to crash.

Steps to reproduce

Use any datamodule providing dictionaries as samples on multi-node environment

Version

0.6.0

@MathiasBaumgartinger MathiasBaumgartinger changed the title Multiple Workers will cause a "Memory Leak" in Multi-Node Environment [BUG] Usage of Dictionaries will cause a "Memory Leak" in Multi-Node Environment Dec 5, 2024
@adamjstewart adamjstewart added this to the 0.6.3 milestone Dec 5, 2024
@adamjstewart adamjstewart added the datasets Geospatial or benchmark datasets label Dec 5, 2024
@adamjstewart adamjstewart self-assigned this Feb 11, 2025
@adamjstewart
Copy link
Collaborator

adamjstewart commented Feb 11, 2025

Hi @MathiasBaumgartinger, apologies for the delay. This issue slipped under the radar during the AGU/holiday rush and then I got busy with teaching. I'm now looking into this and have read all of pytorch/pytorch#13246.

We've received a few other reports of memory issues, specifically #1438 (@patriksabol), #1578 (@trettelbach), and #1694 (@pmaldonado). @yichiac also reported something similar but didn't open an issue. I'm now wondering if what we thought was an issue with GDAL's cache was actually an issue with copy-on-write multiprocessing behavior. Or it's possible that Rtree or Python's LRU cache behave similarly to Python lists/dicts.

From talking to the other maintainers, it isn't clear if the issue is due to the fact that we return dicts, or due to the fact that we store information in lists/dicts as dataset attributes. I'll also be investigating this and report back once I've found a good reproducer.

@adamjstewart
Copy link
Collaborator

adamjstewart commented Feb 11, 2025

Can anyone share a specific builtin dataset/datamodule that they have encountered this issue with? A YAML file with the settings you used would be especially helpful. I haven't yet managed to reproduce the issue with the datasets I've tried, but I also haven't yet found a multi-node environment I can test on. Also, what tools do you use to visualize memory usage, just the builtin Activity Monitor?

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

No branches or pull requests

2 participants