Scalene memory profiling with DDP(Lightning AI): total memory does not increase with more processes #1016
Unanswered
belfaunder
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hello, I have a question about using Scalene to profile memory in a distributed training setup with DDP. I observed behavior that I do not fully understand:
When I run my workload with 1 process, Scalene reports about the same total memory usage as when I run it with 10 processes (all on CPU). However, when I measure memory usage with
psutil,I see a clear increase, roughly from 0.8 GB to 3.7 GB. Because of this, I am unsure how to interpret Scalene’s memory numbers in a multi-process / DDP setup: does it report memory utilization only for the main process? And if so, are there settings that allow to get an aggregated memory consumption over all processes?How to reproduce:
Run:
scalene run --memory main.py,Environment
Python: 3.12.3
lightning 2.6.1
scalene: 2.1.4
torch: 2.10.0
torchvision: 0.25.0
OS: Ubuntu 24.04 running under WSL2
Minimal reproduction example
The full code of main.py module for reproducing is based on example from Lightning AI (https://lightning.ai/docs/pytorch/stable/notebooks/lightning_examples/mnist-hello-world.html):
Screenshots of the reports for 10 and 1 process runs
Additional information
Maybe this issue from Memray is relevant, as it has an issue with following Lightning AI processes because of
fork+execv(bloomberg/memray#33).All reactions