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

enable option to disable pin_memory in pytorch #239

Merged
merged 2 commits into from
Oct 30, 2024

Conversation

rayandrew
Copy link
Contributor

Hi @zhenghh04 and @hariharan-devarajan,

This PR gives us option to disable pin memory in pytorch dataloader.
I encountered error while emulating stormer when we increase the prefetch factor since the memory is being reserved and cannot be released until the dataloader is finished.
Also, pin_memory is beneficial for GPU memory pinning which we do not use at all for DLIO [1, 2]

I set the default to True for backward compatibility, let me know if I should put pin_memory=False as default in the configuration.

Reference:
[1] https://pytorch.org/tutorials/intermediate/pinmem_nonblock.html
[2] https://discuss.pytorch.org/t/when-to-set-pin-memory-to-true/19723/19

@rayandrew
Copy link
Contributor Author

Along with this PR, just want to point out the prefetch factor below while having discussion with @hariharan-devarajan recently

# torch_data_loader.py
        if self._args.read_threads >= 1:
            prefetch_factor = math.ceil(self._args.prefetch_size / self._args.read_threads)
        else:
            prefetch_factor = self._args.prefetch_size

Here, we limit the prefetch factor based on number of threads. Is it intended?
Probably it is better from user perspective to put everything as prefetch factor without making assumption that this number will be divided by number of workers.

@hariharan-devarajan
Copy link
Collaborator

Along with this PR, just want to point out the prefetch factor below while having discussion with @hariharan-devarajan recently

# torch_data_loader.py
        if self._args.read_threads >= 1:
            prefetch_factor = math.ceil(self._args.prefetch_size / self._args.read_threads)
        else:
            prefetch_factor = self._args.prefetch_size

Here, we limit the prefetch factor based on number of threads. Is it intended? Probably it is better from user perspective to put everything as prefetch factor without making assumption that this number will be divided by number of workers.

@zhenghh04 I agree with Ray that this is confusing for users of the benchmark. I would recommend to not do this.

Copy link
Collaborator

@hariharan-devarajan hariharan-devarajan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good. Thanks

@zhenghh04 zhenghh04 merged commit c9225fb into argonne-lcf:main Oct 30, 2024
6 checks passed
@rayandrew rayandrew deleted the feature/add-pin-memory-options branch November 4, 2024 21:57
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.

3 participants