Functions 58
caching_allocator_alloc
functionFull reference ↗caching_allocator_delete
functionFull reference ↗- tensorplay.cuda.caching_allocator_delete(mem_ptr)[source]
Delete memory allocated using the CUDA memory allocator.
can_device_access_peer
functionFull reference ↗change_current_allocator
functionFull reference ↗- tensorplay.cuda.change_current_allocator(alloc)[source]
Change the currently used memory allocator (not supported by this build).
check_error
functionFull reference ↗classproperty
functionFull reference ↗clock_rate
functionFull reference ↗cudart
functionFull reference ↗- tensorplay.cuda.cudart()[source]
Retrieves the CUDA runtime API module.
This function initializes the CUDA runtime environment if it is not already initialized and returns the CUDA runtime API module (_cudart).
- Returns:
The CUDA runtime API module, or
Nonewhen no ctypes runtime binding is exposed by this build.- Return type:
module or None
current_blas_handle
functionFull reference ↗- tensorplay.cuda.current_blas_handle()[source]
Return cublasHandle_t pointer to current cuBLAS handle
current_device
functionFull reference ↗current_solver_handle
functionFull reference ↗- tensorplay.cuda.current_solver_handle()[source]
Return cusolverDnHandle_t pointer to current cuSOLVER handle
current_stream
functionFull reference ↗- tensorplay.cuda.current_stream(device: Any = None) Stream[source]
Return the currently selected
Streamfor a given device.- Parameters:
device (tensorplay.Device or int, optional) – selected device. Returns the currently selected
Streamfor the current device, given bycurrent_device(), ifdeviceisNone(default).
default_stream
functionFull reference ↗- tensorplay.cuda.default_stream(device: Any = None) Stream[source]
Return the default
Streamfor a given device.- Parameters:
device (tensorplay.Device or int, optional) – selected device. Returns the default
Streamfor the current device, given bycurrent_device(), ifdeviceisNone(default).
device_count
functionFull reference ↗device_memory_used
functionFull reference ↗- tensorplay.cuda.device_memory_used(device: Any = None) int[source]
Return used global (device) memory in bytes as given by nvidia-smi.
- Parameters:
device (tensorplay.Device or int, optional) – selected device. Returns statistic for the current device, given by
current_device(), ifdeviceisNone(default).
empty_cache
functionFull reference ↗- tensorplay.cuda.empty_cache() None[source]
Release all unoccupied cached memory currently held by the caching allocator so that those can be used in other GPU application and visible in nvidia-smi.
Note
empty_cache()doesn’t increase the amount of GPU memory available for TensorPlay. However, it may help reduce fragmentation of GPU memory in certain cases.
get_allocator_backend
functionFull reference ↗get_arch_list
functionFull reference ↗get_device_capability
functionFull reference ↗- tensorplay.cuda.get_device_capability(device: Any = None) tuple[int, int][source]
Get the cuda capability of a device.
- Parameters:
device (tensorplay.Device or int or str, optional) – device for which to return the device capability. This function is a no-op if this argument is a negative integer. It uses the current device, given by
current_device(), ifdeviceisNone(default).- Returns:
the major and minor cuda capability of the device
- Return type:
get_device_name
functionFull reference ↗- tensorplay.cuda.get_device_name(device: Any = None) str[source]
Get the name of a device.
- Parameters:
device (tensorplay.Device or int or str, optional) – device for which to return the name. This function is a no-op if this argument is a negative integer. It uses the current device, given by
current_device(), ifdeviceisNone(default).- Returns:
the name of the device
- Return type:
get_device_properties
functionFull reference ↗- tensorplay.cuda.get_device_properties(device: Any = None) _CudaDeviceProperties[source]
Get the properties of a device.
- Parameters:
device (tensorplay.Device or int or str, optional) – device for which to return the properties of the device. It uses the current device, given by
current_device(), ifdeviceisNone(default).- Returns:
the properties of the device
- Return type:
_CudaDeviceProperties
get_gencode_flags
functionFull reference ↗get_per_process_memory_fraction
functionFull reference ↗get_stream_from_external
functionFull reference ↗get_sync_debug_mode
functionFull reference ↗host_memory_stats_as_nested_dict
functionFull reference ↗- tensorplay.cuda.host_memory_stats_as_nested_dict() dict[str, Any][source]
Return the result of
host_memory_stats()as a nested dictionary.
host_memory_stats
functionFull reference ↗init
functionFull reference ↗- tensorplay.cuda.init()[source]
Initialize TensorPlay’s CUDA state.
You may need to call this explicitly if you are interacting with TensorPlay via its C API, as Python bindings for CUDA functionality will not be available until this initialization takes place. Ordinary users should not need this, as all of TensorPlay’s CUDA methods automatically initialize CUDA state on-demand.
Does nothing if the CUDA state is already initialized.
ipc_collect
functionFull reference ↗- tensorplay.cuda.ipc_collect()[source]
Force collects GPU memory after it has been released by CUDA IPC.
is_available
functionFull reference ↗is_bf16_supported
functionFull reference ↗is_gds_available
functionFull reference ↗is_initialized
functionFull reference ↗- tensorplay.cuda.is_initialized()[source]
Return whether TensorPlay’s CUDA state has been initialized.
is_tf32_supported
functionFull reference ↗list_gpu_processes
functionFull reference ↗max_memory_allocated
functionFull reference ↗- tensorplay.cuda.max_memory_allocated(device: Any = None) int[source]
Return the maximum GPU memory occupied by tensors in bytes for a given device.
By default, this returns the peak allocated memory since the beginning of this program.
reset_peak_memory_stats()can be used to reset the starting point in tracking this metric.- Parameters:
device (tensorplay.Device or int, optional) – selected device. Returns statistic for the current device, given by
current_device(), ifdeviceisNone(default).
max_memory_reserved
functionFull reference ↗- tensorplay.cuda.max_memory_reserved(device: Any = None) int[source]
Return the maximum GPU memory managed by the caching allocator in bytes for a given device.
- Parameters:
device (tensorplay.Device or int, optional) – selected device. Returns statistic for the current device, given by
current_device(), ifdeviceisNone(default).
mem_get_info
functionFull reference ↗memory_allocated
functionFull reference ↗- tensorplay.cuda.memory_allocated(device: Any = None) int[source]
Return the current GPU memory occupied by tensors in bytes for a given device.
- Parameters:
device (tensorplay.Device or int, optional) – selected device. Returns statistic for the current device, given by
current_device(), ifdeviceisNone(default).
memory_reserved
functionFull reference ↗- tensorplay.cuda.memory_reserved(device: Any = None) int[source]
Return the current GPU memory managed by the caching allocator in bytes for a given device.
- Parameters:
device (tensorplay.Device or int, optional) – selected device. Returns statistic for the current device, given by
current_device(), ifdeviceisNone(default).
memory_snapshot
functionFull reference ↗- tensorplay.cuda.memory_snapshot(mempool_id=None, include_traces=True)[source]
Return a snapshot of the CUDA memory allocator state across all devices.
Interpreting the output of this function requires familiarity with the memory allocator internals. Not exposed by this TensorPlay build.
memory_stats_as_nested_dict
functionFull reference ↗- tensorplay.cuda.memory_stats_as_nested_dict(device: Any = None) dict[str, Any][source]
Return the result of
memory_stats()as a nested dictionary.The native allocator reports the fragmentation-aware matrix directly (segments, free-block histogram, pending cross-stream blocks, graph pools, capture state); it is exposed under
"allocator"alongside the
memory_stats
functionFull reference ↗- tensorplay.cuda.memory_stats(device: Any = None) dict[str, Any][source]
Return a dictionary of CUDA memory allocator statistics for a given device.
The return value of this function is a dictionary of statistics, each of the full key layout; keys that are not tracked by this TensorPlay build are always reported as zero.
- Parameters:
device (tensorplay.Device or int, optional) – selected device. Returns statistics for the current device, given by
current_device(), ifdeviceisNone(default).
memory_summary
functionFull reference ↗- tensorplay.cuda.memory_summary(device: Any = None, abbreviated: bool = False) str[source]
Return a human-readable printout of the current memory allocator statistics for a given device.
This can be useful to display periodically during training, or when handling out-of-memory exceptions.
- Parameters:
device (tensorplay.Device or int, optional) – selected device. Returns printout for the current device, given by
current_device(), ifdeviceisNone(default).abbreviated (bool, optional) – whether to return an abbreviated summary (default: False).
memory_usage
functionFull reference ↗- tensorplay.cuda.memory_usage(device: Any = None) int[source]
Return the percent of time over the past sample period during which global (device) memory was being read or written as given by nvidia-smi.
Warning: Each sample period may be between 1 second and 1/6 second, depending on the product being queried.
power_draw
functionFull reference ↗reset_accumulated_host_memory_stats
functionFull reference ↗reset_accumulated_memory_stats
functionFull reference ↗reset_peak_host_memory_stats
functionFull reference ↗reset_peak_memory_stats
functionFull reference ↗- tensorplay.cuda.reset_peak_memory_stats(device: Any = None) None[source]
Reset the “peak” stats tracked by the CUDA memory allocator.
Peak stats correspond to the “peak” key in each individual stat dict.
- Parameters:
device (tensorplay.Device or int, optional) – selected device. Returns statistic for the current device, given by
current_device(), ifdeviceisNone(default).
set_device
functionFull reference ↗- tensorplay.cuda.set_device(device: Any) None[source]
Set the current device.
Usage of this function is discouraged in favor of
device. In most cases it’s better to useCUDA_VISIBLE_DEVICESenvironmental variable.- Parameters:
device (tensorplay.Device or int) – selected device. This function is a no-op if this argument is negative.
set_per_process_memory_fraction
functionFull reference ↗- tensorplay.cuda.set_per_process_memory_fraction(fraction, device: Any = None) None[source]
Set memory fraction for a process.
Not enforced by this TensorPlay build; the signature is retained for API compatibility.
- Parameters:
fraction (float) – Range: 0~1. Allowed memory equals total_memory * fraction.
device (tensorplay.Device or int, optional) – selected device.
set_stream
functionFull reference ↗set_sync_debug_mode
functionFull reference ↗stream
functionFull reference ↗- tensorplay.cuda.stream(stream_: Stream | None) StreamContext[source]
Wrap around the Context-manager StreamContext that selects a given stream.
- Parameters:
stream (Stream) – selected stream. This manager is a no-op if it’s
None.
Note
Streams are per-device.
synchronize
functionFull reference ↗- tensorplay.cuda.synchronize(device: Any = None) None[source]
Wait for all kernels in all streams on a CUDA device to complete.
- Parameters:
device (tensorplay.Device or int, optional) – device for which to synchronize. It uses the current device, given by
current_device(), ifdeviceisNone(default).
temperature
functionFull reference ↗utilization
functionFull reference ↗- tensorplay.cuda.utilization(device: Any = None) int[source]
Return the percent of time over the past sample period during which one or more kernels was executing on the GPU as given by nvidia-smi.
Warning: Each sample period may be between 1 second and 1/6 second, depending on the product being queried.
Classes 6
CUDAPluggableAllocator
classFull reference ↗device_of
classFull reference ↗- class tensorplay.cuda.device_of(obj)[source]
Context-manager that changes the current device to that of given object.
You can use both tensors and storages as arguments. If a given object is not allocated on a GPU, this is a no-op.
- Parameters:
obj (Tensor or Storage) – object allocated on the selected device.
device
classFull reference ↗- class tensorplay.cuda.device(device: Any)[source]
Context-manager that changes the selected device.
- Parameters:
device (tensorplay.Device or int) – device index to select. It’s a no-op if this argument is a negative integer or
None.
Device
classFull reference ↗MemPool
classFull reference ↗- class tensorplay.cuda.MemPool(*args, **kwargs)[source]
MemPool context (not supported by this TensorPlay build).
StreamContext
classFull reference ↗- class tensorplay.cuda.StreamContext(stream: Stream | None)[source]
Context-manager that selects a given stream.
All CUDA kernels queued within its context will be enqueued on a selected stream.
- Parameters:
Stream (Stream) – selected stream. This manager is a no-op if it’s
None.
Note
Streams are per-device.
Exceptions 4
AcceleratorError
exceptionFull reference ↗- exception tensorplay.cuda.AcceleratorError[source]
CudaError
exceptionFull reference ↗DeferredCudaCallError
exceptionFull reference ↗- exception tensorplay.cuda.DeferredCudaCallError[source]
OutOfMemoryError
exceptionFull reference ↗- exception tensorplay.cuda.OutOfMemoryError[source]

