GreenContext
- class torch.cuda.green_contexts.GreenContext(*, num_sms=None, workqueue_scope=None, workqueue_concurrency_limit=None, device_id=None)
Wrapper around a CUDA green context.
CUDA work should be placed on streams created from the green context:
ctx = GreenContext(...)
stream = ctx.Stream()
with torch.cuda.stream(stream):
# torch operations here are using resources from `ctx`
pass
Green-context streams are custom CUDA streams. Synchronization with other streams is the user’s responsibility and should be handled with CUDA events, as with any other custom stream.
Return a CUDA stream associated with this green context.
Use the returned stream with torch.cuda.stream() to run work on
the green context. Synchronization with other streams is not automatic;
use CUDA events as with any other custom stream.
Create a CUDA green context.
Kept for compatibility, see GreenContext constructor.
Return the maximum workqueue concurrency limit for the device.
This queries the device for the default number of concurrent stream-ordered workloads supported by workqueue configuration resources.
Assuming the green context is the current context, pop it from the context stack and restore the previous context.
Deprecated. Create streams with Stream() and use
torch.cuda.stream() instead.
Make the green context the current context.
Deprecated. Create streams with Stream() and use
torch.cuda.stream() instead.