Skip to content

num_workers in VideoClips initialization #1307

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

Closed
ekosman opened this issue Sep 7, 2019 · 4 comments
Closed

num_workers in VideoClips initialization #1307

ekosman opened this issue Sep 7, 2019 · 4 comments

Comments

@ekosman
Copy link
Contributor

ekosman commented Sep 7, 2019

I've been trying to create a VideoClips object from a very large dataset, however during the process my system restarts for some unknown reason.
After looking in here I figured out that I never get into the loop (line 85).
Running torch.get_num_threads() gives me 44, so I changed this to 16 manually and it works fine now.

  import torch.utils.data
        dl = torch.utils.data.DataLoader(
            DS(self.video_paths),
            batch_size=16,
            num_workers=torch.get_num_threads(), # changed this to 16
            collate_fn=lambda x: x)

I think it would be better to let the user choose the num_workers parameter by passing it to VideoClips constructor.

@fmassa
Copy link
Member

fmassa commented Sep 11, 2019

Yes, I agree that this option should be exposed, but I was not very convinced that it should be an argument to VideoClips constructor.

But I don't see any better solution than that, so exposing it to the constructor might be the best thing we can do, with a default value of 1 maybe?

@ekosman
Copy link
Contributor Author

ekosman commented Sep 12, 2019

@fmassa Another option is to use torch.set_num_workers(), but I don't know how this would affect the behavior of other functions. Therefore I think the best thing to do is exposing it to the constructor with the default value as you suggested.

@fmassa
Copy link
Member

fmassa commented Sep 16, 2019

Yes, I agree. I'd be happy to accept a PR adding the constructor argument to VideoClips

@fmassa
Copy link
Member

fmassa commented Sep 23, 2019

Fixed in #1359

@fmassa fmassa closed this as completed Sep 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants