@@ -32,10 +32,13 @@ from libcpp.string cimport string
32
32
from cuda.cudart import cudaError_t
33
33
34
34
from rmm._cuda.gpu import CUDARuntimeError, getDevice, setDevice
35
+
35
36
from rmm._cuda.stream cimport Stream
37
+
36
38
from rmm._cuda.stream import DEFAULT_STREAM
37
39
38
40
from rmm._lib.cuda_stream_view cimport cuda_stream_view
41
+ from rmm._lib.helper cimport parse_bytes
39
42
from rmm._lib.memory_resource cimport (
40
43
available_device_memory as c_available_device_memory,
41
44
percent_of_free_device_memory as c_percent_of_free_device_memory,
@@ -44,6 +47,7 @@ from rmm._lib.per_device_resource cimport (
44
47
cuda_device_id,
45
48
set_per_device_resource as cpp_set_per_device_resource,
46
49
)
50
+
47
51
from rmm.statistics import Statistics
48
52
49
53
# Transparent handle of a C++ exception
@@ -314,9 +318,9 @@ cdef class CudaAsyncMemoryResource(DeviceMemoryResource):
314
318
315
319
Parameters
316
320
----------
317
- initial_pool_size : int, optional
321
+ initial_pool_size : int | str , optional
318
322
Initial pool size in bytes. By default, half the available memory
319
- on the device is used.
323
+ on the device is used. A string argument is parsed using `parse_bytes`.
320
324
release_threshold: int, optional
321
325
Release threshold in bytes. If the pool size grows beyond this
322
326
value, unused memory held by the pool will be released at the
@@ -334,7 +338,7 @@ cdef class CudaAsyncMemoryResource(DeviceMemoryResource):
334
338
cdef optional[size_t] c_initial_pool_size = (
335
339
optional[size_t]()
336
340
if initial_pool_size is None
337
- else optional[size_t](< size_t> initial_pool_size)
341
+ else optional[size_t](< size_t> parse_bytes( initial_pool_size) )
338
342
)
339
343
340
344
cdef optional[size_t] c_release_threshold = (
@@ -426,12 +430,12 @@ cdef class PoolMemoryResource(UpstreamResourceAdaptor):
426
430
c_initial_pool_size = (
427
431
c_percent_of_free_device_memory(50 ) if
428
432
initial_pool_size is None
429
- else initial_pool_size
433
+ else parse_bytes( initial_pool_size)
430
434
)
431
435
c_maximum_pool_size = (
432
436
optional[size_t]() if
433
437
maximum_pool_size is None
434
- else optional[size_t](< size_t> maximum_pool_size)
438
+ else optional[size_t](< size_t> parse_bytes( maximum_pool_size) )
435
439
)
436
440
self .c_obj.reset(
437
441
new pool_memory_resource[device_memory_resource](
@@ -456,10 +460,10 @@ cdef class PoolMemoryResource(UpstreamResourceAdaptor):
456
460
upstream_mr : DeviceMemoryResource
457
461
The DeviceMemoryResource from which to allocate blocks for the
458
462
pool.
459
- initial_pool_size : int, optional
463
+ initial_pool_size : int | str , optional
460
464
Initial pool size in bytes. By default, half the available memory
461
465
on the device is used.
462
- maximum_pool_size : int, optional
466
+ maximum_pool_size : int | str , optional
463
467
Maximum size in bytes, that the pool can grow to.
464
468
"""
465
469
pass
@@ -1091,8 +1095,10 @@ cpdef void _initialize(
1091
1095
typ = PoolMemoryResource
1092
1096
args = (upstream(),)
1093
1097
kwargs = dict (
1094
- initial_pool_size = initial_pool_size,
1095
- maximum_pool_size = maximum_pool_size
1098
+ initial_pool_size = None if initial_pool_size is None
1099
+ else parse_bytes(initial_pool_size),
1100
+ maximum_pool_size = None if maximum_pool_size is None
1101
+ else parse_bytes(maximum_pool_size)
1096
1102
)
1097
1103
else :
1098
1104
typ = upstream
0 commit comments