Skip to content

RandCropByPosNegLabeld triggers CPU memory overflow when num_sample is very large. #1574

@Jingnan-Jia

Description

@Jingnan-Jia

In the function of RandCropByPosNegLabeld, I found that when I set num_samples = 100 (randomly crop 100 3D patches from a high-resolution CT scan), the CPU memory would overflow. This is because all the samples would be generated before they are passed to the next transform which occupy a great number of CPU memory.

I think you can/should use generator to generate samples one by one or batch by batch with a lazy manner so that we can set num_samples any great number.

For example, do not return 100 patches in one time. just yield one patch in one time.

I think you can also learn the manner in sliding_window_inference where the patches are predicted patch by patch. In this manner, we can divide the whole image to as many as patches we need.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions