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

Add gpus argument for chainerrl.misc.set_random_seed #207

Merged
merged 2 commits into from Dec 22, 2017

Conversation

muupan
Copy link
Member

@muupan muupan commented Dec 21, 2017

  • Add gpus argument to chainerrl.misc.set_random_seed to set a seed of cupy.random as well as random and numpy.random.
  • Add docstring and tests

@muupan
Copy link
Member Author

muupan commented Dec 21, 2017

The test passed with cupy and a single gpu.

I also manually checked with two gpus:

$ python -c "import cupy; import chainerrl; chainerrl.misc.set_random_seed(0, gpus=(0,1)); cupy.cuda.Device(0).use(); print(cupy.random.rand())"
0.5615491552815766
$ python -c "import cupy; import chainerrl; chainerrl.misc.set_random_seed(0, gpus=(0,1)); cupy.cuda.Device(1).use(); print(cupy.random.rand())"
0.5615491552815766
$ python -c "import cupy; import chainerrl; chainerrl.misc.set_random_seed(1, gpus=(0,1)); cupy.cuda.Device(0).use(); print(cupy.random.rand())"
0.27550817398125504
$ python -c "import cupy; import chainerrl; chainerrl.misc.set_random_seed(1, gpus=(0,1)); cupy.cuda.Device(1).use(); print(cupy.random.rand())"
0.27550817398125504

Copy link
Member

@toslunar toslunar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Let me leave a survey on seeds.

  • random.seed (with the current default version=2) uses all the bits of int.
  • numpy.random.seed accepts int in [0, 2 ** 32).
  • cupy.random.seed accepts int that can be casted safely to uint64.

@toslunar toslunar merged commit 5d2507d into chainer:master Dec 22, 2017
@muupan muupan added this to the v0.4 milestone Jul 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants