Skip to content
Discussion options

You must be logged in to vote

The issue was resolved by adding a conditional structure to handle the type of the samples object before sending it to the device. Specifically, the following logic was used in the training loop (or wherever samples is processed):

if isinstance(samples, list):
    samples = samples[1].to(device, non_blocking=True)
else:
    samples = samples.to(device, non_blocking=True)

This approach ensures compatibility with both:

  • Locally stored datasets in SageMaker, where samples is already a tensor.
  • Datasets loaded using S3torchconnector.S3MapDataset, where samples is returned as a list (e.g., a tuple like (key, tensor)).

By checking the type and selecting the appropriate element (in this case, sa…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by DavidMacha
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants