Skip to content

Does the use of np.random.RandomState compromise randomness when used in multiprocessed PyTorch DataLoader? #2020

@Antymon

Description

@Antymon

I have noticed that the PyTorch datasets implementations leverage np.random.RandomState.

I do wonder whether this might result in compromising pseudo-randomness in multiprocess scenarios:

PyTorch uses multiprocessing to load data in parallel. The worker processes are created using the fork start method. This means each worker process inherits all resources of the parent, including the state of NumPy’s random number generator.

A detailed explanation of the problem I have in mind is available here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions