Rate this Page

torch.xpu.memory.set_per_process_memory_fraction#

torch.xpu.memory.set_per_process_memory_fraction(fraction, device=None)[source]#

Set the memory fraction for a single process on XPU device. This function limits the amount of memory that the caching allocator can allocate on the specified XPU device. The allowed memory is computed as:

allowed_memory=total_memory×fraction\text{allowed\_memory} = \text{total\_memory} \times \text{fraction}

If the process attempts to allocate more than this allowed memory, an out-of-memory error will be raised by the allocator.

Parameters
  • fraction (float) – Range: 0~1. Allowed memory equals total_memory * fraction.

  • device (torch.device or int or str, optional) – selected device. It uses the current device, given by current_device(), if device is None (default).

Note

In general, the total available free memory is less than the total capacity.