# tensorplay.cuda.random API Source: https://www.tensorplay.cn/docs/api/tensorplay.cuda.random.html ## Functions 9 [#](#api-tensorplay.cuda.random.get_rng_state_all) ### get_rng_state_all function[Full reference ↗](/docs/generated/tensorplay.cuda.random.get_rng_state_all.html) ```python tensorplay.cuda.random.get_rng_state_all() → list[Tensor] ``` Return a list of ByteTensor representing the random number states of all devices. [#](#api-tensorplay.cuda.random.get_rng_state) ### get_rng_state function[Full reference ↗](/docs/generated/tensorplay.cuda.random.get_rng_state.html) ```python tensorplay.cuda.random.get_rng_state(device: int | str | Any = 'cuda') → Tensor ``` Return the random number generator state of the specified GPU as a ByteTensor. Parameters: device ([tensorplay.Device](/docs/generated/tensorplay.Device.html#tensorplay.Device) or [int](https://docs.python.org/3/builtins/functions.html#int), optional) – The device to return the RNG state of. Default: 'cuda' (i.e., the current CUDA device). > **Warning** > > This function eagerly initializes CUDA. [#](#api-tensorplay.cuda.random.initial_seed) ### initial_seed function[Full reference ↗](/docs/generated/tensorplay.cuda.random.initial_seed.html) ```python tensorplay.cuda.random.initial_seed() → int ``` Return the current random seed of the current GPU. > **Warning** > > This function eagerly initializes CUDA. [#](#api-tensorplay.cuda.random.manual_seed_all) ### manual_seed_all function[Full reference ↗](/docs/generated/tensorplay.cuda.random.manual_seed_all.html) ```python tensorplay.cuda.random.manual_seed_all(seed: int) → None ``` Set the seed for generating random numbers on all GPUs. It’s safe to call this function if CUDA is not available; in that case, it is silently ignored. Parameters: seed ([int](https://docs.python.org/3/builtins/functions.html#int)) – The desired seed. [#](#api-tensorplay.cuda.random.manual_seed) ### manual_seed function[Full reference ↗](/docs/generated/tensorplay.cuda.random.manual_seed.html) ```python tensorplay.cuda.random.manual_seed(seed: int) → None ``` Set the seed for generating random numbers for the current GPU. It’s safe to call this function if CUDA is not available; in that case, it is silently ignored. Parameters: seed ([int](https://docs.python.org/3/builtins/functions.html#int)) – The desired seed. > **Warning** > > If you are working with a multi-GPU model, this function is insufficient to get determinism. To seed all GPUs, use manual_seed_all(). [#](#api-tensorplay.cuda.random.seed_all) ### seed_all function[Full reference ↗](/docs/generated/tensorplay.cuda.random.seed_all.html) ```python tensorplay.cuda.random.seed_all() → None ``` Set the seed for generating random numbers to a random number on all GPUs. It’s safe to call this function if CUDA is not available; in that case, it is silently ignored. [#](#api-tensorplay.cuda.random.seed) ### seed function[Full reference ↗](/docs/generated/tensorplay.cuda.random.seed.html) ```python tensorplay.cuda.random.seed() → None ``` Set the seed for generating random numbers to a random number for the current GPU. It’s safe to call this function if CUDA is not available; in that case, it is silently ignored. > **Warning** > > If you are working with a multi-GPU model, this function will only initialize the seed on one GPU. To initialize all GPUs, use seed_all(). [#](#api-tensorplay.cuda.random.set_rng_state_all) ### set_rng_state_all function[Full reference ↗](/docs/generated/tensorplay.cuda.random.set_rng_state_all.html) ```python tensorplay.cuda.random.set_rng_state_all(new_states: Iterable[Tensor]) → None ``` Set the random number generator state of all devices. Parameters: new_states (Iterable of ByteTensor) – The desired state for each device. [#](#api-tensorplay.cuda.random.set_rng_state) ### set_rng_state function[Full reference ↗](/docs/generated/tensorplay.cuda.random.set_rng_state.html) ```python tensorplay.cuda.random.set_rng_state(new_state: Tensor, device: int | str | Any = 'cuda') → None ``` Set the random number generator state of the specified GPU. Parameters: - new_state (ByteTensor) – The desired state - device ([tensorplay.Device](/docs/generated/tensorplay.Device.html#tensorplay.Device) or [int](https://docs.python.org/3/builtins/functions.html#int), optional) – The device to set the RNG state. Default: 'cuda' (i.e., the current CUDA device).