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

One random number generator per GPU #52

Closed
dominikgrewe opened this issue Oct 6, 2014 · 5 comments
Closed

One random number generator per GPU #52

dominikgrewe opened this issue Oct 6, 2014 · 5 comments
Labels

Comments

@dominikgrewe
Copy link
Member

Currently there's a single random number generator shared between all GPUs. The way it is set up seems to indicate that we really want one generator per GPU, but that's not what's happening:
In luaopen_libcutorch we call THCudaInit which itself calls THRandom_manualSeed for each GPU, each time creating a new generator and replacing the old one. We then call THCRandom_seed which again replaces the previously created generator with a new one.

Before #45 we'd only call THCRandom_manualSeed in cutorch_setDevice but that seems equally wrong.

If we want one generator per GPU we should create N generators at initialization and then pick the one for the currently chosen device when generating random numbers. Any thoughts?

@soumith
Copy link
Member

soumith commented Oct 6, 2014

You are right, our RNG code in cutorch might be broken. I haven't noticed it because I dont use it.

@soumith
Copy link
Member

soumith commented Oct 6, 2014

we might need a static array of generators and switch to the appropriate one on setDevice

@dominikgrewe
Copy link
Member Author

Yes, that's what I had in mind too. We could even create them lazily in setDevice, thus only occurring the overhead if we really use multiple GPUs.

@soumith
Copy link
Member

soumith commented Oct 6, 2014

lazy sounds good too (though I doubt the overhead matters :) )

@soumith soumith added the bug label Oct 6, 2014
@dominikgrewe
Copy link
Member Author

Fixed by #53

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

No branches or pull requests

2 participants