Skip to content
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

[Feature] How to customize the worker_init_fn function #933

Closed
Hughen opened this issue Feb 16, 2023 · 1 comment · Fixed by #1038
Closed

[Feature] How to customize the worker_init_fn function #933

Hughen opened this issue Feb 16, 2023 · 1 comment · Fixed by #1038
Assignees

Comments

@Hughen
Copy link

Hughen commented Feb 16, 2023

What is the feature?

When I use the train_dataloader parameter of the dict type, I want to customize the worker_init_fn process, but I see that the source code does not support passing this parameter, so how can I implement some initialization work that is important to me in the dataset subprocess?

Expect:

def my_custom_worker_init(*args, **kwargs):
    print("my custom worker_init_fn", args, kwargs)


train_dataloader = dict(
    dataset=dict(
        type="CustomDataset"
    ),
    worker_init_fn=my_custom_worker_init,
)

Any other context?

No response

@HAOCHENYE
Copy link
Collaborator

Currently, MMEngine does not support customizing the worker_init_fn. But we plan to add a new registry: FUNCTIONS, from which collate_fn and worker_init_fn are built. The implementation is very similar to collate_fn. Are you interested to creating a PR to support this feature? We will also help you throughout the process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants