TensorPlay
API reference
latest (dev)
Copy
View Markdown

Latest development documentation · Updated 2026-10-15

tensorplay.cuda.random API

Functions 9

#

get_rng_state_all

functionFull reference ↗
tensorplay.cuda.random.get_rng_state_all() → list[Tensor][source]

Return a list of ByteTensor representing the random number states of all devices.

#

get_rng_state

functionFull reference ↗
tensorplay.cuda.random.get_rng_state(device: int | str | Any = 'cuda') → Tensor[source]

Return the random number generator state of the specified GPU as a ByteTensor.

Parameters:

device (tensorplay.Device or int, optional) – The device to return the RNG state of. Default: 'cuda' (i.e., the current CUDA device).

Warning

This function eagerly initializes CUDA.

#

initial_seed

functionFull reference ↗
tensorplay.cuda.random.initial_seed() → int[source]

Return the current random seed of the current GPU.

Warning

This function eagerly initializes CUDA.

#

manual_seed_all

functionFull reference ↗
tensorplay.cuda.random.manual_seed_all(seed: int) → None[source]

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) – The desired seed.

#

manual_seed

functionFull reference ↗
tensorplay.cuda.random.manual_seed(seed: int) → None[source]

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) – 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().

#

seed_all

functionFull reference ↗
tensorplay.cuda.random.seed_all() → None[source]

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.

#

seed

functionFull reference ↗
tensorplay.cuda.random.seed() → None[source]

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().

#

set_rng_state_all

functionFull reference ↗
tensorplay.cuda.random.set_rng_state_all(new_states: Iterable[Tensor]) → None[source]

Set the random number generator state of all devices.

Parameters:

new_states (Iterable of ByteTensor) – The desired state for each device.

#

set_rng_state

functionFull reference ↗
tensorplay.cuda.random.set_rng_state(new_state: Tensor, device: int | str | Any = 'cuda') → None[source]

Set the random number generator state of the specified GPU.

Parameters:
  • new_state (ByteTensor) – The desired state

  • device (tensorplay.Device or int, optional) – The device to set the RNG state. Default: 'cuda' (i.e., the current CUDA device).

On this page

Ask DeepWiki