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

[BUG] all augmentation pipeline were on the same GPU #115

Merged
merged 1 commit into from
Jan 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions ffcv/loader/epoch_iterator.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ def __init__(self, loader: 'Loader', order: Sequence[int]):
self.terminate_event = Event()
self.memory_context = self.loader.memory_manager.schedule_epoch(
batches)

if IS_CUDA:
self.current_stream = ch.cuda.current_stream()

try:
self.memory_context.__enter__()
except MemoryError as e:
Expand Down Expand Up @@ -96,7 +100,7 @@ def run(self):
# and make sure no one overwrite the data until they are done
just_finished_slot = (slot - self.loader.batches_ahead) % (self.loader.batches_ahead + 2)
event = ch.cuda.Event()
event.record(ch.cuda.default_stream())
event.record(self.current_stream)
events[just_finished_slot] = event
b_ix += 1

Expand Down Expand Up @@ -146,7 +150,7 @@ def __next__(self):
if IS_CUDA:
stream = self.cuda_streams[slot]
# We wait for the copy to be done
ch.cuda.current_stream().wait_stream(stream)
self.current_stream.wait_stream(stream)
return result

def __iter__(self):
Expand Down