NVIDIA / NVIDIA/DALI

Dynamic slicing and batch size

Open
#5,671 7 comments 0 reactions 1 assignee View on GitHub

@klecki is already working on this.

Since Oct 9, 2024.

question Video
Dominant language
C++
Stars
5.8k
Forks
678
Avg merge
3d 1h
Merged PRs (30d)
27

Description

Describe the question.

Hello everyone,

I'm trying to optimise a torch data loading pipeline that involves video decoding and thought I'd give DALI a try (already tried things like pynvvideocodec but that ended up quite slow). I have something more or less working but at the cost of some suboptimal decisions so I'm wondering whether I missed relevant options or whether DALI is not perfectly suited for my use case.

I have a set of N 1s videos, where N changes from batch to batch, and I want to extract a certain number of frames from those videos, where the indices of the frames differ from video to video. From reading other posts, it does seem at the frontier of what DALI was designed for.

I have set up an ExternalInputCallable class with batch=False (in order to leverage parallelism) where __call__ returns a video and list of indices, and a pipeline based on fn.experimental.decoders.video.

The questions I have are the following:

  • how can I handle the dynamic number of videos per batch? I tried setting up a pipeline batch size larger than the max number of videos and a StopIteration in the external source but it doesn't seem to work. I could reinitialise the pipeline with the appropriate batch size every time, but it seems wasteful.
  • is there a way to compose fn.element_extract and decoding at the sample level in the pipeline? Right now I'm doing the slicing per sample on a torch tensor built from each tensorGPU returned by pipeline.run(), which feels very inefficient.
  • or maybe a different setup is more appropriate?
Check for duplicates
  • I have searched the open bugs/issues and have found no duplicates for this bug report

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.