Skip to content

Commit

Permalink
Optmize data transfer
Browse files Browse the repository at this point in the history
  • Loading branch information
Flova committed Feb 5, 2025
1 parent d29db0e commit 213d285
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ddlitlab2024/ml/training/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
collate_fn=DDLITLab2024Dataset.collate_fn,
persistent_workers=num_workers > 1,
# prefetch_factor=10 * num_workers,
pin_memory=True,
num_workers=num_workers,
worker_init_fn=worker_init_fn,
)
Expand Down Expand Up @@ -178,7 +179,7 @@
# Iterate over the dataset
for _i, batch in enumerate(pbar := tqdm(dataloader)):
# Move the data to the device
batch = {k: v.to(device) for k, v in asdict(batch).items() if v is not None}
batch = {k: v.to(device, non_blocking=True) for k, v in asdict(batch).items() if v is not None}

# Extract the target actions
joint_targets = batch["joint_command"]
Expand Down

0 comments on commit 213d285

Please sign in to comment.