Project-MONAI / Project-MONAI/MONAI

VideoDataset Deadlock and error

Open
#8,322 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
8.7k
Forks
1.6k
Avg merge
5d 1h
Merged PRs (30d)
20

Description

Describe the bug

OpenCV VideoCapture object deadlocks the data loader or throws different errors when multiple workers try to access the same video file. The current logic implemented in the dataset is workable for Linux env but not Windows. The self.multiprocessing attribute doesn't prevent num_worker > 0 from being handled either.

To Reproduce
dataset = VideoFileDataset(video_source = "video.mp4", multiprocessing = True)
dataloader = torch.utils.data.Dataloader(dataset, batch_size = 2, num_worker = 2)
for batch in dataloader:
print(hello)

Expected behaviour
Dataloader will deadlock when trying to create the same cv2.VideoCapture object on same video (behaviour could be different in different video files)

Screenshots
If applicable, add screenshots to help explain your problem.

Environment

Windows
Pyhton > 3.9

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.

Research direction

Start with VideoFileDataset and its cv2.VideoCapture handling, then run the provided torch.utils.data.Dataloader reproduction on Windows with num_worker=2. Compare behavior when multiple workers access video.mp4; done means the reported deadlock and inconsistent errors are eliminated while dataset loading still works.

Written by the indexing model from the issue text.

Assessment

Tech stack
opencv, python
Domain
data, machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.