cuda.core.system._device.DeviceEvents#
- class cuda.core.system._device.DeviceEvents(intptr_t device_handle: intptr_t, events: EventType | str | list[EventType | str])#
Represents a set of events that can be waited on for a specific device.
Methods
- __init__(*args, **kwargs)#
- wait(self, int timeout_ms: int = 0) EventData#
Wait for events in the event set.
For Fermi™ or newer fully supported devices.
If some events are ready to be delivered at the time of the call, function returns immediately. If there are no events ready to be delivered, function sleeps until event arrives but not longer than specified timeout. If timeout passes, a
cuda.core.system.TimeoutErroris raised. This function in certain conditions can return before specified timeout passes (e.g. when interrupt arrives).On Windows, in case of Xid error, the function returns the most recent Xid error type seen by the system. If there are multiple Xid errors generated before
waitis invoked, then the last seen Xid error type is returned for all Xid error events.On Linux, every Xid error event would return the associated event data and other information if applicable.
In MIG mode, if device handle is provided, the API reports all the events for the available instances, only if the caller has appropriate privileges. In absence of required privileges, only the events which affect all the instances (i.e. whole device) are reported.
This API does not currently support per-instance event reporting using MIG device handles.
- Parameters:
timeout_ms (int) – The timeout in milliseconds. A default value of 0 means to skip waiting.
- Raises:
cuda.core.system.TimeoutError – If the timeout expires before an event is received.
cuda.core.system.GpuIsLostError – If the GPU has fallen off the bus or is otherwise inaccessible.
Notes
Waits on this event set are serialized by a lock. A synchronous wait can block while another wait is running; use
wait_async()from an event loop.
- async wait_async(self, timeout_ms: int = 0) EventData#
Wait asynchronously for an event in the event set.
Waits without blocking the event loop. Unlike
wait(), a timeout of 0 waits indefinitely. The native wait is issued in bounded slices, so cancelling the awaiting task stops the wait within a slice instead of parking a thread for the remaining timeout. An event that a cancelled slice already consumed is delivered to the next wait on this event set rather than being dropped.- Parameters:
timeout_ms (int) – The timeout in milliseconds. A value of 0 means to wait indefinitely.
- Returns:
The event that was received.
- Return type:
EventData- Raises:
cuda.core.system.TimeoutError – If the timeout expires before an event is received.
cuda.core.system.GpuIsLostError – If the GPU has fallen off the bus or is otherwise inaccessible.
ValueError – If
timeout_msis negative.
Notes
Waits on this event set are serialized by a lock. Time spent waiting for another consumer counts against the timeout budget. If a native error occurs while a cancelled wait is draining, it is raised by the next wait on this event set; the cancelled task still propagates
asyncio.CancelledError.