mehta-lab / VisCy

computer vision models for single-cell phenotyping
https://pypi.org/project/viscy/
BSD 3-Clause "New" or "Revised" License
36 stars 3 forks source link

OOM issues with 3D FCMAE fine-tuning #201

Open edyoshikun opened 6 days ago

edyoshikun commented 6 days ago

Currently if we use the ddp and the fcmae model for fine-tuning for the virtual staining tasks, there seems to be a 'memory leak'. The solution could be to expose these parameters at the ViscyTrainer.

Using PyTorch Lightning’s CombinedLoader with Distributed Data Parallel (DDP spawns multiple processes (one per GPU) and seems to lead to excessive accumulation in a subset of worker processes. Setting persistent_workers=False restarts the DataLoader workers at the beginning of each epoch, which prevents the accumulation of memory or disk space. There is a performance trade-off here as well as reducing the hardcoded prefetch factor from 4 to 2.

edyoshikun commented 6 days ago

Using the prefetch=4 vs prefetch=2 has no effect on the training speed for the neuromast VS training. Here we are mostly limited by CPU->GPU pipes.