Spaces:
Running on Zero
Running on Zero
File size: 505 Bytes
052cbee | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | """Serialize the shared CUDA handlers on Modal without ZeroGPU leases."""
from functools import wraps
from threading import RLock
lock = RLock()
after_call = None
def GPU(*, duration=None):
def decorate(function):
@wraps(function)
def invoke(*args, **kwargs):
with lock:
result = function(*args, **kwargs)
if after_call is not None:
after_call()
return result
return invoke
return decorate
|