Skip to content

Conversation

@yhy258
Copy link

@yhy258 yhy258 commented Dec 18, 2025

This is for the issue #307 . (Closes #307 )

When I finetuned the sam3 with a large dataset (like larger than 1M 2D images), I faced the memory leak problem in the dataloader.

Then, I followed this post: https://ppwwyyxx.com/blog/2022/Demystify-RAM-Usage-in-Multiprocess-DataLoader/, and it worked well (torch-serialization).

If we want to use the torch-serialization method, we can just adjust the coco_json_loader component in yaml file.
Please just add grouped_serialzation: true like this:

data:
    train:
      _target_: sam3.train.data.torch_dataset.TorchDataset
      dataset:
        _target_: sam3.train.data.sam3_image_dataset.Sam3ImageDataset
        limit_ids: ${biomedseg2d_train.num_images}
        transforms: ${biomedseg2d_train.train_transforms}
        load_segmentation: ${scratch.enable_segmentation}
        coco_json_loader:
          _target_: sam3.train.data.coco_json_loaders.COCO_FROM_JSON
          category_chunk_size: 2
          grouped_serialzation: true # !!!
          _partial_: true

@meta-cla
Copy link

meta-cla bot commented Dec 18, 2025

Hi @yhy258!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@meta-cla
Copy link

meta-cla bot commented Dec 18, 2025

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Dec 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Memory Leakage Problem?

1 participant