torch.accelerator#
Created On: Oct 27, 2024 | Last Updated On: Nov 13, 2025
This package introduces support for the currentaccelerator in python.
device_count | Return the number of currentaccelerator available. |
is_available | Check if the current accelerator is available at runtime: it was build, all the required drivers are available and at least one device is visible. |
current_accelerator | Return the device of the accelerator available at compilation time. |
set_device_index | Set the current device index to a given device. |
set_device_idx | (Deprecated) Set the current device index to a given device. |
current_device_index | Return the index of a currently selected device for the currentaccelerator. |
current_device_idx | (Deprecated) Return the index of a currently selected device for the currentaccelerator. |
set_stream | Set the current stream to a given stream. |
current_stream | Return the currently selected stream for a given device. |
synchronize | Wait for all kernels in all streams on the given device to complete. |
device_index | Context manager to set the current device index for the currentaccelerator. |
Memory management#
empty_cache | Release all unoccupied cached memory currently held by the caching allocator so that those can be used in other application. |
get_memory_info | Return the current device memory information for a given device index. |
max_memory_allocated | Return the currentaccelerator maximum device memory occupied by tensors in bytes for a given device index. |
max_memory_reserved | Return the currentaccelerator maximum device memory managed by the caching allocator in bytes for a given device index. |
memory_allocated | Return the currentaccelerator device memory occupied by tensors in bytes for a given device index. |
memory_reserved | Return the currentaccelerator device memory managed by the caching allocator in bytes for a given device index. |
memory_stats | Return a dictionary of accelerator device memory allocator statistics for a given device index. |
reset_accumulated_memory_stats | Reset the "accumulated" (historical) stats tracked by the currentaccelerator memory allocator for a given device index. |
reset_peak_memory_stats | Reset the "peak" stats tracked by the currentaccelerator memory allocator for a given device index. |