@@ -329,24 +329,19 @@ def __init__(self, device_id: int):
329329 # Set a higher release threshold to improve performance when there are no active allocations.
330330 # By default, the release threshold is 0, which means memory is immediately released back
331331 # to the OS when there are no active suballocations, causing performance issues.
332- try :
333- # Check current release threshold
334- current_threshold = handle_return (
335- driver .cuMemPoolGetAttribute (self ._handle , driver .CUmemPool_attribute .CU_MEMPOOL_ATTR_RELEASE_THRESHOLD )
336- )
337- # If threshold is 0 (default), set it to maximum to retain memory in the pool
338- if int (current_threshold ) == 0 :
339- handle_return (
340- driver .cuMemPoolSetAttribute (
341- self ._handle ,
342- driver .CUmemPool_attribute .CU_MEMPOOL_ATTR_RELEASE_THRESHOLD ,
343- driver .cuuint64_t (0xFFFFFFFFFFFFFFFF ),
344- )
332+ # Check current release threshold
333+ current_threshold = handle_return (
334+ driver .cuMemPoolGetAttribute (self ._handle , driver .CUmemPool_attribute .CU_MEMPOOL_ATTR_RELEASE_THRESHOLD )
335+ )
336+ # If threshold is 0 (default), set it to maximum to retain memory in the pool
337+ if int (current_threshold ) == 0 :
338+ handle_return (
339+ driver .cuMemPoolSetAttribute (
340+ self ._handle ,
341+ driver .CUmemPool_attribute .CU_MEMPOOL_ATTR_RELEASE_THRESHOLD ,
342+ driver .cuuint64_t (0xFFFFFFFFFFFFFFFF ),
345343 )
346- except Exception :
347- # If setting the attribute fails (e.g., on older drivers), continue without error
348- # to maintain backward compatibility
349- pass
344+ )
350345
351346 def allocate (self , size : int , stream : Stream = None ) -> Buffer :
352347 """Allocate a buffer of the requested size.
0 commit comments