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

Fixing memory leak on low-power devices #6

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

yaroslavorl
Copy link

Thanks for your wonderful repository segVlad!

When working with your repository, I encountered a problem with memory overflow and leakage due to loading the same model in a loop and storing all extracted vectors in RAM. With a large dataset, this error is critical.

The following fixes are suggested:

1. Added chunks = True to avoid RAM overflow on large datasets or low-power devices

grp.create_dataset ("ift_dino", data=ift_dino.detach().cpu().numpy(), chunks=True)

2. The model configuration dict and model load function have been moved above the dataset loop to avoid re-initialization and memory overflow when using large models.

if SAM_extraction:
        cfg_sam = {"desired_width": width_SAM, "desired_height": height_SAM, "detect": 'dino', "use_sam": True,
                   "class_threshold": 0.9,
                   "desired_feature": 0, "query_type": 'text', "sort_by": 'area', "use_16bit": False,
                   "use_cuda": True,
                   "dino_strides": 4, "use_traced_model": False,
                   "rmin": 0, "DAStoreFull": False, "dinov2": True, "wrap": False,
                   "resize": True}  # robohop specifc params

        print("SAM extraction started...")
        SAM = func_vpr.loadSAM(sam_checkpoint, cfg_sam, device="cuda")

        for iter_dict in list_all:
            ...

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

Successfully merging this pull request may close these issues.

1 participant