Skip to content

Conversation

@colesbury
Copy link
Member

DataLoader now supports the constructor argument 'pin_memory'. When set
to true, tensors in the sample are copied to pinned memory. This happens
in a background thread when num_workers > 1.

DataLoader now supports the constructor argument 'pin_memory'. When set
to true, tensors in the sample are copied to pinned memory. This happens
in a background thread when num_workers > 1.
Copy link
Contributor

@apaszke apaszke left a comment

Choose a reason for hiding this comment

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

Didn't you forget to clean up the thread when the iter is destructed?

@colesbury
Copy link
Member Author

The thread is cleaned up the same way as the background processes: None is passed in the input queue to signal shutdown. The background processes forward the None message to the output queue (which is the thread's input queue).

There's a test for this in test_dataloader.lua

@colesbury colesbury merged commit aea6ba4 into pytorch:master Nov 29, 2016
@colesbury colesbury deleted the pin_memory branch November 29, 2016 17:35
KyleCZH pushed a commit to KyleCZH/pytorch that referenced this pull request Sep 20, 2021
Revert "Adding another build env to conda builds"
eellison pushed a commit to eellison/pytorch that referenced this pull request Jun 29, 2022
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.

2 participants